feature/research-di #1
@ -17,8 +17,6 @@ type customerDbResponse = {
|
|||||||
|
|
||||||
export default class CustomerDbRepo implements CustomerRepo {
|
export default class CustomerDbRepo implements CustomerRepo {
|
||||||
async fetchList(query: string): Promise<Customer[]> {
|
async fetchList(query: string): Promise<Customer[]> {
|
||||||
// This is equivalent to in fetch(..., {cache: 'no-store'}).
|
|
||||||
connection()
|
|
||||||
try {
|
try {
|
||||||
const data = await sql`
|
const data = await sql`
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -4,8 +4,10 @@ import serverDi from "@/feature/common/server-di";
|
|||||||
import { customerKey } from "@/feature/core/customer/customer-key";
|
import { customerKey } from "@/feature/core/customer/customer-key";
|
||||||
import Customer from "@/feature/core/customer/domain/entity/customer";
|
import Customer from "@/feature/core/customer/domain/entity/customer";
|
||||||
import CustomerRepo, { customerRepoKey } from "@/feature/core/customer/domain/i-repo/customer-repo";
|
import CustomerRepo, { customerRepoKey } from "@/feature/core/customer/domain/i-repo/customer-repo";
|
||||||
|
import { connection } from "next/server";
|
||||||
|
|
||||||
export default async function fetchCustomersUsecase(query: string): Promise<Customer[]> {
|
export default async function fetchCustomersUsecase(query: string): Promise<Customer[]> {
|
||||||
|
connection()
|
||||||
const repo = serverDi(customerKey).resolve<CustomerRepo>(customerRepoKey)
|
const repo = serverDi(customerKey).resolve<CustomerRepo>(customerRepoKey)
|
||||||
|
|
||||||
return repo.fetchList(query)
|
return repo.fetchList(query)
|
||||||
|
@ -10,7 +10,6 @@ export type RevenueDbResponse = {
|
|||||||
};
|
};
|
||||||
export default class RevenueDbRepo implements RevenueRepo {
|
export default class RevenueDbRepo implements RevenueRepo {
|
||||||
async fetchRevenues(): Promise<Revenue[]> {
|
async fetchRevenues(): Promise<Revenue[]> {
|
||||||
// This is equivalent to in fetch(..., {cache: 'no-store'}).
|
|
||||||
try {
|
try {
|
||||||
// Artificially delay a response for demo purposes.
|
// Artificially delay a response for demo purposes.
|
||||||
// Don't do this in production :)
|
// Don't do this in production :)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user