Skip to content

Commit 8d51618

Browse files
committed
fix(func): use new service hook to make upgrading easier
1 parent 9e4de45 commit 8d51618

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/dependencies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function sortByKey(deps: Record<string, string>) {
1010
export function dependencies({ features }: { features: string[] }) {
1111
const deps = {
1212
'@openapi-typescript-infra/coconfig': '^3.0.2',
13-
'@openapi-typescript-infra/service': '^1.0.1',
13+
'@openapi-typescript-infra/service': '^1.1.0',
1414
} as Record<string, string>;
1515
if (features.includes('db')) {
1616
Object.assign(deps, {
@@ -29,7 +29,7 @@ export function dependencies({ features }: { features: string[] }) {
2929
export function devDependencies({ features }: { features: string[] }) {
3030
const deps = {
3131
coconfig: '^0.10.1',
32-
'@openapi-typescript-infra/service-tester': '^1.0.3',
32+
'@openapi-typescript-infra/service-tester': '^1.0.5',
3333
'@typescript-eslint/eslint-plugin': '^5.59.7',
3434
'@typescript-eslint/parser': '^5.59.7',
3535
'@types/jest': '^29.5.1',

templates/all/src/index.ts.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useService } from '@openapi-typescript-infra/service';
12
{{#inArray features 'redis'}}
23
import Redis from 'ioredis';{{/inArray}}{{#inArray features 'db'}}
34
import { Pool } from 'pg';
@@ -11,8 +12,11 @@ import type { {{properCase name}}Service, {{properCase name}}ConfigSchema } from
1112
type Config = {{properCase name}}ConfigSchema;
1213

1314
export function service(): {{properCase name}}Service {
15+
const base = useService();
1416
return {
17+
...base,
1518
async start(app) {
19+
await base.start(app);
1620
// Load and configure your service wide infra here
1721
{{#inArray features 'db'}}
1822
const db = new Kysely<DB>({
@@ -34,6 +38,7 @@ export function service(): {{properCase name}}Service {
3438
});
3539
},
3640
async stop(app) {
41+
await base.stop(app);
3742
const { locals } = app;
3843
// Shutdown any service wide infra here
3944
{{#inArray features 'db'}}

0 commit comments

Comments
 (0)