A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ pnpm install
Start containers in detached / background mode
$ docker-compose up -d
Stop containers
$ docker-compose down**
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:cov
/* typeorm-cli.config.ts */
export default new DataSource({
type: 'postgres',
host: 'localhost',
port: 5432,
username: 'postgres',
password: 'pass123',
database: 'postgres',
entities: [],
migrations: [],
});
$ npx typeorm migration:create src/migrations/CoffeeRefactor
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`ALTER TABLE "coffee" RENAME COLUMN "name" TO "title"`,
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`ALTER TABLE "coffee" RENAME COLUMN "title" TO "name"`,
);
}
💡 IMPORTANT 💡 You must BUILD your Nest project (so that everything is output to the
/dist/
folder, before a Migration can run, it needs compiled files.
// Compile project first
$ pnpm run build
// Run migration(s)
$ npx typeorm migration:run -d dist/typeorm-cli.config
// REVERT migration(s)
$ npx typeorm migration:revert -d dist/typeorm-cli.config
// Let TypeOrm generate migrations (for you)
$ npx typeorm migration:generate src/migrations/SchemaSync -d dist/typeorm-cli.config
- If the error message is "aggregateError":
When running nestjs project I have the issue:
aggregateError:
at internalConnectMultiple (node:net:1114:18)
at afterConnectMultiple (node:net:1667:5)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)
Waiting for the debugger to disconnect..
The error message, "AggregateError," typically indicates that there was an issue when connecting to a network resource. In a NestJS application, this could relate to issues with connecting to databases, external services, or other network-related operations.
- Check Database Connection: if NestJS application is connecting to a database, ensure that the database server is up and running, and that the connection details (such as host, port, username, and password) are correctly configured in your application's configuration file, check your
.env
file.
On this case run Docker compose to start database container:
$ docker-compose up -d
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.