GithubHelp home page GithubHelp logo

nestjs-sequelize-typescript's Introduction

Nest

Description

Starter kit project made with Nest that demonstrates CRUD user, JWT authentication, CRUD posts and e2e tests.

Technologies implemented:

Prerequisites

Installation

$ npm install

Setting up the database for development and test

PostgreSQL database connection options are shown in the following table:

Option Development Test
Host localhost localhost
Port 5432 5432
Username postgres postgres
Password postgres postgres
Database nest nest_test

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# e2e tests
$ npm run test

Other commands

# formatting code
$ npm run format

# run linter
$ npm run lint

# create database
$ npm run db:create

# run migrations
$ npm run db:migrate

# run seeders
$ npm run db:seed-dev

# reset database
$ npm run db:reset

# drop database
$ npm run db:drop

Run production configuration

NODE_ENV=production \
DATABASE_HOST=db.host.com \
DATABASE_PORT=5432 \
DATABASE_USER=user \
DATABASE_PASSWORD=pass \
DATABASE_DATABASE=database \
JWT_PRIVATE_KEY=jwtPrivateKey \
ts-node -r tsconfig-paths/register src/main.ts

Swagger API docs

This project uses the Nest swagger module for API documentation. NestJS Swagger - www.swagger.io
Swagger docs will be available at localhost:3000/documentation

nestjs-sequelize-typescript's People

Contributors

dependabot[bot] avatar kentloog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nestjs-sequelize-typescript's Issues

[Question] Application runtime port?

$ npm install
$ npm run start || npm run start:dev

> [email protected] start:dev C:\Users\.....
> nodemon

[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): src\**\*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[Nest] 10564   - 2021. 11. 05. 오후 5:52:26   [NestFactory] Starting Nest application...
[Nest] 10564   - 2021. 11. 05. 오후 5:52:26   [InstanceLoader] AppModule dependencies initialized +11ms
[Nest] 10564   - 2021. 11. 05. 오후 5:52:26   [InstanceLoader] SharedModule dependencies initialized +0ms
[Nest] 10564   - 2021. 11. 05. 오후 5:52:26   [InstanceLoader] PostsModule dependencies initialized +92ms
[Nest] 10564   - 2021. 11. 05. 오후 5:52:26   [InstanceLoader] UsersModule dependencies initialized +0ms

What port is the application running on?

ex) localhost:3000

getting error in creating production build: npm run start:prod

[email protected] start:dev /home/ideal21/Documents/NestJs/nestjs-sequelize-typescript
nodemon

[nodemon] 1.18.11
[nodemon] to restart at any time, enter rs
[nodemon] watching: /home/ideal21/Documents/NestJs/nestjs-sequelize-typescript/src/**/*
[nodemon] starting ts-node -r tsconfig-paths/register src/main.ts
[Nest] 12469 - 05/15/2019, 9:43 AM [NestFactory] Starting Nest application...
[Nest] 12469 - 05/15/2019, 9:43 AM [InstanceLoader] AppModule dependencies initialized +26ms
[Nest] 12469 - 05/15/2019, 9:43 AM [InstanceLoader] SharedModule dependencies initialized +0ms
[Nest] 12469 - 05/15/2019, 9:43 AM [InstanceLoader] PostsModule dependencies initialized +339ms
[Nest] 12469 - 05/15/2019, 9:43 AM [InstanceLoader] UsersModule dependencies initialized +2ms
(node:12469) [SEQUELIZE0002] DeprecationWarning: The logging-option should be either a function or false. Default: console.log
Executing (default): CREATE TABLE IF NOT EXISTS user (id CHAR(36) BINARY , email VARCHAR(255) UNIQUE, password VARCHAR(255), first_name VARCHAR(255), last_name VARCHAR(255), gender ENUM('female', 'male'), birthday DATE, created_at DATETIME, updated_at DATETIME, deleted_at DATETIME, PRIMARY KEY (id)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM user FROM nest
Executing (default): CREATE TABLE IF NOT EXISTS post (id BIGINT auto_increment , user_id CHAR(36) BINARY, title VARCHAR(255), content VARCHAR(255), created_at DATETIME, updated_at DATETIME, deleted_at DATETIME, PRIMARY KEY (id), FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM post FROM nest
[Nest] 12469 - 05/15/2019, 9:43 AM [InstanceLoader] DatabaseModule dependencies initialized +175ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RoutesResolver] UsersController {/users}: +363ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/register, POST} route +8ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/login, POST} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/, GET} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/me, GET} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/me, PUT} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/me, DELETE} route +1ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RoutesResolver] PostsController {/posts}: +1ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/, GET} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/:id, GET} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/, POST} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/:id, PUT} route +1ms
[Nest] 12469 - 05/15/2019, 9:43 AM [RouterExplorer] Mapped {/:id, DELETE} route +2ms
[Nest] 12469 - 05/15/2019, 9:43 AM [NestApplication] Nest application successfully started +5ms
^C
ideal21@ideal21:~/Documents/NestJs/nestjs-sequelize-typescript$ npm run start:prod

[email protected] prestart:prod /home/ideal21/Documents/NestJs/nestjs-sequelize-typescript
rimraf dist && npm run build

[email protected] build /home/ideal21/Documents/NestJs/nestjs-sequelize-typescript
tsc -p tsconfig.build.json

[email protected] start:prod /home/ideal21/Documents/NestJs/nestjs-sequelize-typescript
node dist/main.js

internal/modules/cjs/loader.js:584
throw err;
^

Error: Cannot find module '/home/ideal21/Documents/NestJs/nestjs-sequelize-typescript/dist/main.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start:prod: node dist/main.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/ideal21/.npm/_logs/2019-05-15T04_13_37_533Z-debug.log

Error npm start with Dockerfile

Hi,

I created a simple Dockerfile:

FROM node:11

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 8080

CMD ["npm", "run", "start"]

But I'm receiving this error:

Error: /usr/src/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:857:18)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/usr/src/app/node_modules/bcrypt/bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/usr/src/app/src/users/users.service.ts:3:1)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Module.m._compile (/usr/src/app/node_modules/ts-node/src/index.ts:439:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/usr/src/app/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/usr/src/app/src/users/users.controller.ts:18:1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ts-node -r tsconfig-paths/register src/main.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

merge DTO and database validation

Is there a way to define the validators for the DB model and the DTO classes at the same time?

Currently the validating decorators have to be copied to both, making updating validation rules more difficult.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.