Skip to content

Commit f8c0e1e

Browse files
author
Matija Petrunić
authored
Merge pull request #1 from NodeFactoryIo/mpetrun5/update
Update
2 parents 3377859 + 15c5f08 commit f8c0e1e

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TYPEORM_MIGRATIONS_DIR=src/migrations
1010
TYPEORM_ENTITIES=src/entities/*.ts
1111
TYPEORM_ENTITIES_DIR=src/entities
1212
TYPEORM_SUBSCRIBERS_DIR=src/subscribers
13+
TYPEORM_SUBSCRIBERS=src/subscribers/*.ts
1314
TYPEORM_SEEDING_FACTORIES=src/services/db/factories/**/*{.ts,.js}
1415
TYPEORM_SEEDING_SEEDS=src/services/db/seeders/**/*{.ts,.js}
1516
TYPEORM_LOGGING=true

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Following software is required to be installed to use this repo:
2323
- `yarn install` - will run and configure everything for you
2424

2525
#### Database
26-
- use `yarn db:migration:new -n <class name>` to generate new migration file (same goes for entity and subscriber)
26+
- use `yarn db:migration:new <class name>` to generate new empty migration file (same goes for entity and subscriber)
27+
- use `docker-compose exec backend yarn db:migration:generate <class name>` to generate new auto generated migration
2728
- `yarn db:migrate` - runs all pending migrations against database
2829
- `yarn db:revert` - reverts last migration, run multiple times to revert everything
2930
- `yarn db:seed` - seeds database with fake data (`src/services/db/seeders`)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"scripts": {
1111
"start:dev": "npx task dev",
1212
"db:migration:new": "yarn run typeorm-ts migration:create -n ",
13+
"db:migration:generate": "yarn run typeorm-ts migration:create -n ",
1314
"db:entity:new": "yarn run typeorm-ts entity:create -n ",
1415
"db:subscriber:new": "yarn run typeorm-ts subscriber:create -n ",
1516
"db:migrate": "npx task npm typeorm-ts migration:run",
@@ -32,7 +33,7 @@
3233
"typeorm-ts": "ts-node ./node_modules/typeorm/cli.js",
3334
"seeder": "ts-node ./node_modules/typeorm-seeding/dist/cli.js",
3435
"start:server": "node --inspect=0.0.0.0:56745 -r ts-node/register -r dotenv/config src/index.ts",
35-
"nodemon": "./node_modules/nodemon/bin/nodemon.js"
36+
"NODE_ENV=development nodemon": "./node_modules/nodemon/bin/nodemon.js"
3637
},
3738
"dependencies": {
3839
"fastify": "^2.13.0",

src/App.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export class App {
5151
});
5252
}
5353

54-
public async stop(): Promise<void> {
54+
public async stop(signal: string): Promise<void> {
5555
await this.instance.close();
56+
process.kill(process.pid, signal);
5657
}
5758

5859
private registerPlugins(): void {
@@ -88,4 +89,4 @@ declare module "fastify" {
8889
config: Config;
8990
db: Connection;
9091
}
91-
}
92+
}

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import nodeCleanup from "node-cleanup";
33

44
const app = new App();
55

6-
nodeCleanup(function () {
7-
app.stop();
6+
nodeCleanup(function (exitCode, signal) {
7+
app.stop(signal as string);
8+
nodeCleanup.uninstall();
9+
return false;
810
});
911

10-
app.start();
12+
app.start();

0 commit comments

Comments
 (0)