typescript-express-starter 10.2.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.kr.md +136 -287
- package/README.md +134 -274
- package/bin/ast-utils.js +226 -0
- package/bin/common.js +312 -0
- package/bin/config.js +80 -0
- package/bin/db-map.js +169 -0
- package/bin/errors.js +129 -0
- package/bin/performance.js +203 -0
- package/bin/starter.js +359 -0
- package/bin/validators.js +146 -0
- package/devtools/biome/.biome.json +34 -0
- package/devtools/biome/.biomeignore +29 -0
- package/devtools/docker/.dockerignore +27 -0
- package/devtools/docker/Dockerfile.dev +20 -0
- package/devtools/docker/Dockerfile.prod +35 -0
- package/{lib/default → devtools/docker}/Makefile +3 -0
- package/devtools/docker/nginx.conf +67 -0
- package/devtools/eslint/eslint.config.cjs +23 -0
- package/devtools/husky/.husky/commit-msg +4 -0
- package/devtools/husky/.husky/pre-commit +4 -0
- package/devtools/husky/.husky/pre-push +4 -0
- package/devtools/jest/jest.config.cjs +2 -0
- package/devtools/jest/jest.config.ts +25 -0
- package/devtools/jest/src/test/e2e/auth.e2e.spec.ts +40 -0
- package/devtools/jest/src/test/e2e/users.e2e.spec.ts +63 -0
- package/devtools/jest/src/test/setup.ts +31 -0
- package/devtools/jest/src/test/unit/entities/user.entity.spec.ts +279 -0
- package/devtools/jest/src/test/unit/services/auth.service.spec.ts +75 -0
- package/devtools/jest/src/test/unit/services/users.service.spec.ts +109 -0
- package/devtools/oxlint/.oxlintrc.json +57 -0
- package/devtools/pm2/ecosystem.config.js +59 -0
- package/devtools/swagger/swagger.yaml +124 -0
- package/{lib/prisma → devtools/swc}/.swcrc +2 -1
- package/devtools/tsup/tsup.config.ts +15 -0
- package/devtools/vitest/src/test/e2e/auth.e2e.spec.ts +41 -0
- package/devtools/vitest/src/test/e2e/users.e2e.spec.ts +64 -0
- package/devtools/vitest/src/test/setup.ts +31 -0
- package/devtools/vitest/src/test/unit/services/auth.service.spec.ts +70 -0
- package/devtools/vitest/src/test/unit/services/users.service.spec.ts +90 -0
- package/devtools/vitest/vitest.config.ts +22 -0
- package/package.json +24 -11
- package/templates/default/nodemon.json +7 -0
- package/templates/default/package.json +48 -0
- package/templates/default/src/app.ts +118 -0
- package/templates/default/src/config/env.ts +78 -0
- package/templates/default/src/controllers/auth.controller.ts +40 -0
- package/templates/default/src/controllers/users.controller.ts +46 -0
- package/templates/default/src/dtos/users.dto.ts +42 -0
- package/templates/default/src/entities/user.entity.ts +190 -0
- package/templates/default/src/exceptions/httpException.ts +14 -0
- package/{lib/knex → templates/default}/src/interfaces/auth.interface.ts +3 -3
- package/templates/default/src/interfaces/users.interface.ts +9 -0
- package/templates/default/src/middlewares/auth.middleware.ts +49 -0
- package/templates/default/src/middlewares/error.middleware.ts +89 -0
- package/templates/default/src/middlewares/notFound.middleware.ts +6 -0
- package/templates/default/src/middlewares/validation.middleware.ts +15 -0
- package/templates/default/src/repositories/users.repository.ts +55 -0
- package/templates/default/src/routes/auth.route.ts +31 -0
- package/templates/default/src/routes/users.route.ts +32 -0
- package/templates/default/src/server.ts +35 -0
- package/templates/default/src/services/auth.service.ts +67 -0
- package/templates/default/src/services/users.service.ts +48 -0
- package/templates/default/src/utils/asyncHandler.ts +8 -0
- package/templates/default/src/utils/logger.ts +113 -0
- package/{lib/typeorm → templates/default}/tsconfig.json +23 -22
- package/CONTRIBUTORS.md +0 -69
- package/bin/cli.js +0 -18
- package/lib/default/.dockerignore +0 -18
- package/lib/default/.editorconfig +0 -9
- package/lib/default/.env.development.local +0 -13
- package/lib/default/.env.production.local +0 -13
- package/lib/default/.env.test.local +0 -13
- package/lib/default/.eslintignore +0 -1
- package/lib/default/.eslintrc +0 -18
- package/lib/default/.huskyrc +0 -5
- package/lib/default/.lintstagedrc.json +0 -5
- package/lib/default/.prettierrc +0 -8
- package/lib/default/.swcrc +0 -39
- package/lib/default/.vscode/launch.json +0 -35
- package/lib/default/.vscode/settings.json +0 -6
- package/lib/default/Dockerfile.dev +0 -18
- package/lib/default/Dockerfile.prod +0 -18
- package/lib/default/docker-compose.yml +0 -35
- package/lib/default/ecosystem.config.js +0 -57
- package/lib/default/jest.config.js +0 -12
- package/lib/default/nginx.conf +0 -40
- package/lib/default/nodemon.json +0 -12
- package/lib/default/package.json +0 -76
- package/lib/default/src/app.ts +0 -81
- package/lib/default/src/config/index.ts +0 -5
- package/lib/default/src/controllers/auth.controller.ts +0 -44
- package/lib/default/src/controllers/users.controller.ts +0 -63
- package/lib/default/src/dtos/users.dto.ts +0 -20
- package/lib/default/src/exceptions/HttpException.ts +0 -10
- package/lib/default/src/http/auth.http +0 -27
- package/lib/default/src/http/users.http +0 -34
- package/lib/default/src/interfaces/auth.interface.ts +0 -15
- package/lib/default/src/interfaces/users.interface.ts +0 -5
- package/lib/default/src/middlewares/auth.middleware.ts +0 -38
- package/lib/default/src/middlewares/error.middleware.ts +0 -15
- package/lib/default/src/middlewares/validation.middleware.ts +0 -27
- package/lib/default/src/models/users.model.ts +0 -9
- package/lib/default/src/routes/auth.route.ts +0 -21
- package/lib/default/src/routes/users.route.ts +0 -23
- package/lib/default/src/server.ts +0 -10
- package/lib/default/src/services/auth.service.ts +0 -52
- package/lib/default/src/services/users.service.ts +0 -51
- package/lib/default/src/test/auth.test.ts +0 -52
- package/lib/default/src/test/users.test.ts +0 -62
- package/lib/default/src/utils/logger.ts +0 -65
- package/lib/default/src/utils/validateEnv.ts +0 -8
- package/lib/default/swagger.yaml +0 -123
- package/lib/default/tsconfig.json +0 -39
- package/lib/graphql/.dockerignore +0 -18
- package/lib/graphql/.editorconfig +0 -9
- package/lib/graphql/.env.development.local +0 -20
- package/lib/graphql/.env.production.local +0 -20
- package/lib/graphql/.env.test.local +0 -20
- package/lib/graphql/.eslintignore +0 -1
- package/lib/graphql/.eslintrc +0 -18
- package/lib/graphql/.huskyrc +0 -5
- package/lib/graphql/.lintstagedrc.json +0 -5
- package/lib/graphql/.prettierrc +0 -8
- package/lib/graphql/.swcrc +0 -40
- package/lib/graphql/.vscode/launch.json +0 -35
- package/lib/graphql/.vscode/settings.json +0 -6
- package/lib/graphql/Dockerfile.dev +0 -19
- package/lib/graphql/Dockerfile.prod +0 -19
- package/lib/graphql/Makefile +0 -46
- package/lib/graphql/docker-compose.yml +0 -58
- package/lib/graphql/ecosystem.config.js +0 -59
- package/lib/graphql/jest.config.js +0 -12
- package/lib/graphql/nginx.conf +0 -40
- package/lib/graphql/nodemon.json +0 -12
- package/lib/graphql/package.json +0 -75
- package/lib/graphql/src/app.ts +0 -107
- package/lib/graphql/src/config/index.ts +0 -6
- package/lib/graphql/src/database/index.ts +0 -26
- package/lib/graphql/src/dtos/users.dto.ts +0 -27
- package/lib/graphql/src/entities/users.entity.ts +0 -26
- package/lib/graphql/src/exceptions/HttpException.ts +0 -10
- package/lib/graphql/src/http/auth.http +0 -49
- package/lib/graphql/src/http/users.http +0 -78
- package/lib/graphql/src/interfaces/auth.interface.ts +0 -14
- package/lib/graphql/src/interfaces/users.interface.ts +0 -5
- package/lib/graphql/src/middlewares/auth.middleware.ts +0 -42
- package/lib/graphql/src/middlewares/error.middleware.ts +0 -15
- package/lib/graphql/src/repositories/auth.repository.ts +0 -53
- package/lib/graphql/src/repositories/users.repository.ts +0 -51
- package/lib/graphql/src/resolvers/auth.resolver.ts +0 -32
- package/lib/graphql/src/resolvers/users.resolver.ts +0 -47
- package/lib/graphql/src/server.ts +0 -10
- package/lib/graphql/src/test/auth.test.ts +0 -10
- package/lib/graphql/src/test/users.test.ts +0 -11
- package/lib/graphql/src/typedefs/users.type.ts +0 -13
- package/lib/graphql/src/utils/logger.ts +0 -77
- package/lib/graphql/src/utils/validateEnv.ts +0 -8
- package/lib/graphql/tsconfig.json +0 -40
- package/lib/knex/.dockerignore +0 -18
- package/lib/knex/.editorconfig +0 -9
- package/lib/knex/.env.development.local +0 -20
- package/lib/knex/.env.production.local +0 -20
- package/lib/knex/.env.test.local +0 -20
- package/lib/knex/.eslintignore +0 -1
- package/lib/knex/.eslintrc +0 -18
- package/lib/knex/.huskyrc +0 -5
- package/lib/knex/.lintstagedrc.json +0 -5
- package/lib/knex/.prettierrc +0 -8
- package/lib/knex/.swcrc +0 -40
- package/lib/knex/.vscode/launch.json +0 -35
- package/lib/knex/.vscode/settings.json +0 -6
- package/lib/knex/Dockerfile.dev +0 -19
- package/lib/knex/Dockerfile.prod +0 -19
- package/lib/knex/Makefile +0 -46
- package/lib/knex/docker-compose.yml +0 -55
- package/lib/knex/ecosystem.config.js +0 -57
- package/lib/knex/jest.config.js +0 -12
- package/lib/knex/knexfile.ts +0 -23
- package/lib/knex/nginx.conf +0 -40
- package/lib/knex/nodemon.json +0 -12
- package/lib/knex/package.json +0 -85
- package/lib/knex/src/app.ts +0 -87
- package/lib/knex/src/config/index.ts +0 -6
- package/lib/knex/src/controllers/auth.controller.ts +0 -44
- package/lib/knex/src/controllers/users.controller.ts +0 -63
- package/lib/knex/src/database/index.ts +0 -24
- package/lib/knex/src/database/migrations/.gitkeep +0 -0
- package/lib/knex/src/database/migrations/20210713110926_initial.ts +0 -17
- package/lib/knex/src/database/seeds/.gitkeep +0 -0
- package/lib/knex/src/dtos/users.dto.ts +0 -20
- package/lib/knex/src/exceptions/HttpException.ts +0 -10
- package/lib/knex/src/http/auth.http +0 -27
- package/lib/knex/src/http/users.http +0 -34
- package/lib/knex/src/interfaces/routes.interface.ts +0 -6
- package/lib/knex/src/interfaces/users.interface.ts +0 -5
- package/lib/knex/src/middlewares/auth.middleware.ts +0 -40
- package/lib/knex/src/middlewares/error.middleware.ts +0 -15
- package/lib/knex/src/middlewares/validation.middleware.ts +0 -27
- package/lib/knex/src/models/users.model.ts +0 -13
- package/lib/knex/src/routes/auth.route.ts +0 -22
- package/lib/knex/src/routes/users.route.ts +0 -23
- package/lib/knex/src/server.ts +0 -10
- package/lib/knex/src/services/auth.service.ts +0 -60
- package/lib/knex/src/services/users.service.ts +0 -55
- package/lib/knex/src/test/auth.test.ts +0 -51
- package/lib/knex/src/test/users.test.ts +0 -65
- package/lib/knex/src/utils/logger.ts +0 -65
- package/lib/knex/src/utils/validateEnv.ts +0 -8
- package/lib/knex/swagger.yaml +0 -123
- package/lib/knex/tsconfig.json +0 -40
- package/lib/mikro-orm/.dockerignore +0 -18
- package/lib/mikro-orm/.editorconfig +0 -9
- package/lib/mikro-orm/.env.development.local +0 -18
- package/lib/mikro-orm/.env.production.local +0 -18
- package/lib/mikro-orm/.env.test.local +0 -18
- package/lib/mikro-orm/.eslintignore +0 -1
- package/lib/mikro-orm/.eslintrc +0 -18
- package/lib/mikro-orm/.huskyrc +0 -5
- package/lib/mikro-orm/.lintstagedrc.json +0 -5
- package/lib/mikro-orm/.prettierrc +0 -8
- package/lib/mikro-orm/.swcrc +0 -41
- package/lib/mikro-orm/.vscode/launch.json +0 -35
- package/lib/mikro-orm/.vscode/settings.json +0 -6
- package/lib/mikro-orm/Dockerfile.dev +0 -19
- package/lib/mikro-orm/Dockerfile.prod +0 -19
- package/lib/mikro-orm/Makefile +0 -46
- package/lib/mikro-orm/docker-compose.yml +0 -55
- package/lib/mikro-orm/ecosystem.config.js +0 -57
- package/lib/mikro-orm/jest.config.js +0 -12
- package/lib/mikro-orm/nginx.conf +0 -40
- package/lib/mikro-orm/nodemon.json +0 -12
- package/lib/mikro-orm/package.json +0 -79
- package/lib/mikro-orm/src/app.ts +0 -97
- package/lib/mikro-orm/src/config/index.ts +0 -6
- package/lib/mikro-orm/src/controllers/auth.controller.ts +0 -44
- package/lib/mikro-orm/src/controllers/users.controller.ts +0 -63
- package/lib/mikro-orm/src/database/index.ts +0 -19
- package/lib/mikro-orm/src/dtos/users.dto.ts +0 -20
- package/lib/mikro-orm/src/entities/base.entity.ts +0 -16
- package/lib/mikro-orm/src/entities/users.entity.ts +0 -17
- package/lib/mikro-orm/src/exceptions/HttpException.ts +0 -10
- package/lib/mikro-orm/src/http/auth.http +0 -32
- package/lib/mikro-orm/src/http/users.http +0 -34
- package/lib/mikro-orm/src/interfaces/auth.interface.ts +0 -15
- package/lib/mikro-orm/src/interfaces/routes.interface.ts +0 -6
- package/lib/mikro-orm/src/interfaces/users.interface.ts +0 -5
- package/lib/mikro-orm/src/middlewares/auth.middleware.ts +0 -39
- package/lib/mikro-orm/src/middlewares/error.middleware.ts +0 -15
- package/lib/mikro-orm/src/middlewares/validation.middleware.ts +0 -27
- package/lib/mikro-orm/src/routes/auth.route.ts +0 -22
- package/lib/mikro-orm/src/routes/users.route.ts +0 -23
- package/lib/mikro-orm/src/server.ts +0 -10
- package/lib/mikro-orm/src/services/auth.service.ts +0 -53
- package/lib/mikro-orm/src/services/users.service.ts +0 -60
- package/lib/mikro-orm/src/test/auth.test.ts +0 -65
- package/lib/mikro-orm/src/test/users.test.ts +0 -69
- package/lib/mikro-orm/src/utils/logger.ts +0 -65
- package/lib/mikro-orm/src/utils/validateEnv.ts +0 -8
- package/lib/mikro-orm/swagger.yaml +0 -122
- package/lib/mikro-orm/tsconfig.json +0 -41
- package/lib/mongoose/.dockerignore +0 -18
- package/lib/mongoose/.editorconfig +0 -9
- package/lib/mongoose/.env.development.local +0 -18
- package/lib/mongoose/.env.production.local +0 -18
- package/lib/mongoose/.env.test.local +0 -18
- package/lib/mongoose/.eslintignore +0 -1
- package/lib/mongoose/.eslintrc +0 -18
- package/lib/mongoose/.huskyrc +0 -5
- package/lib/mongoose/.lintstagedrc.json +0 -5
- package/lib/mongoose/.prettierrc +0 -8
- package/lib/mongoose/.swcrc +0 -40
- package/lib/mongoose/.vscode/launch.json +0 -35
- package/lib/mongoose/.vscode/settings.json +0 -6
- package/lib/mongoose/Dockerfile.dev +0 -19
- package/lib/mongoose/Dockerfile.prod +0 -19
- package/lib/mongoose/Makefile +0 -46
- package/lib/mongoose/docker-compose.yml +0 -55
- package/lib/mongoose/ecosystem.config.js +0 -57
- package/lib/mongoose/jest.config.js +0 -12
- package/lib/mongoose/nginx.conf +0 -40
- package/lib/mongoose/nodemon.json +0 -12
- package/lib/mongoose/package.json +0 -78
- package/lib/mongoose/src/app.ts +0 -87
- package/lib/mongoose/src/config/index.ts +0 -6
- package/lib/mongoose/src/controllers/auth.controller.ts +0 -44
- package/lib/mongoose/src/controllers/users.controller.ts +0 -63
- package/lib/mongoose/src/database/index.ts +0 -18
- package/lib/mongoose/src/dtos/users.dto.ts +0 -20
- package/lib/mongoose/src/exceptions/HttpException.ts +0 -10
- package/lib/mongoose/src/http/auth.http +0 -27
- package/lib/mongoose/src/http/users.http +0 -34
- package/lib/mongoose/src/interfaces/auth.interface.ts +0 -15
- package/lib/mongoose/src/interfaces/routes.interface.ts +0 -6
- package/lib/mongoose/src/interfaces/users.interface.ts +0 -5
- package/lib/mongoose/src/middlewares/auth.middleware.ts +0 -39
- package/lib/mongoose/src/middlewares/error.middleware.ts +0 -15
- package/lib/mongoose/src/middlewares/validation.middleware.ts +0 -27
- package/lib/mongoose/src/models/users.model.ts +0 -16
- package/lib/mongoose/src/routes/auth.route.ts +0 -22
- package/lib/mongoose/src/routes/users.route.ts +0 -23
- package/lib/mongoose/src/server.ts +0 -10
- package/lib/mongoose/src/services/auth.service.ts +0 -52
- package/lib/mongoose/src/services/users.service.ts +0 -54
- package/lib/mongoose/src/test/auth.test.ts +0 -83
- package/lib/mongoose/src/test/index.test.ts +0 -18
- package/lib/mongoose/src/test/users.test.ts +0 -133
- package/lib/mongoose/src/utils/logger.ts +0 -65
- package/lib/mongoose/src/utils/validateEnv.ts +0 -8
- package/lib/mongoose/swagger.yaml +0 -120
- package/lib/mongoose/tsconfig.json +0 -40
- package/lib/node-postgres/.dockerignore +0 -18
- package/lib/node-postgres/.editorconfig +0 -9
- package/lib/node-postgres/.env.development.local +0 -20
- package/lib/node-postgres/.env.production.local +0 -20
- package/lib/node-postgres/.env.test.local +0 -20
- package/lib/node-postgres/.eslintignore +0 -1
- package/lib/node-postgres/.eslintrc +0 -18
- package/lib/node-postgres/.huskyrc +0 -5
- package/lib/node-postgres/.lintstagedrc.json +0 -5
- package/lib/node-postgres/.prettierrc +0 -8
- package/lib/node-postgres/.swcrc +0 -38
- package/lib/node-postgres/.vscode/launch.json +0 -35
- package/lib/node-postgres/.vscode/settings.json +0 -6
- package/lib/node-postgres/Dockerfile.dev +0 -17
- package/lib/node-postgres/Dockerfile.prod +0 -17
- package/lib/node-postgres/Makefile +0 -46
- package/lib/node-postgres/docker-compose.yml +0 -61
- package/lib/node-postgres/ecosystem.config.js +0 -57
- package/lib/node-postgres/jest.config.js +0 -12
- package/lib/node-postgres/nginx.conf +0 -40
- package/lib/node-postgres/nodemon.json +0 -12
- package/lib/node-postgres/package.json +0 -78
- package/lib/node-postgres/src/app.ts +0 -81
- package/lib/node-postgres/src/config/index.ts +0 -6
- package/lib/node-postgres/src/controllers/auth.controller.ts +0 -44
- package/lib/node-postgres/src/controllers/users.controller.ts +0 -63
- package/lib/node-postgres/src/database/index.ts +0 -10
- package/lib/node-postgres/src/database/init.sql +0 -13
- package/lib/node-postgres/src/dtos/users.dto.ts +0 -20
- package/lib/node-postgres/src/exceptions/httpException.ts +0 -10
- package/lib/node-postgres/src/http/auth.http +0 -27
- package/lib/node-postgres/src/http/users.http +0 -34
- package/lib/node-postgres/src/interfaces/auth.interface.ts +0 -15
- package/lib/node-postgres/src/interfaces/routes.interface.ts +0 -6
- package/lib/node-postgres/src/interfaces/users.interface.ts +0 -5
- package/lib/node-postgres/src/middlewares/auth.middleware.ts +0 -46
- package/lib/node-postgres/src/middlewares/error.middleware.ts +0 -15
- package/lib/node-postgres/src/middlewares/validation.middleware.ts +0 -27
- package/lib/node-postgres/src/routes/auth.route.ts +0 -21
- package/lib/node-postgres/src/routes/users.route.ts +0 -23
- package/lib/node-postgres/src/server.ts +0 -10
- package/lib/node-postgres/src/services/auth.service.ts +0 -103
- package/lib/node-postgres/src/services/users.service.ts +0 -133
- package/lib/node-postgres/src/test/auth.test.ts +0 -57
- package/lib/node-postgres/src/test/users.test.ts +0 -72
- package/lib/node-postgres/src/utils/logger.ts +0 -65
- package/lib/node-postgres/src/utils/validateEnv.ts +0 -8
- package/lib/node-postgres/swagger.yaml +0 -123
- package/lib/node-postgres/tsconfig.json +0 -39
- package/lib/prisma/.dockerignore +0 -18
- package/lib/prisma/.editorconfig +0 -9
- package/lib/prisma/.env.development.local +0 -16
- package/lib/prisma/.env.production.local +0 -16
- package/lib/prisma/.env.test.local +0 -16
- package/lib/prisma/.eslintignore +0 -1
- package/lib/prisma/.eslintrc +0 -18
- package/lib/prisma/.huskyrc +0 -5
- package/lib/prisma/.lintstagedrc.json +0 -5
- package/lib/prisma/.prettierrc +0 -8
- package/lib/prisma/.vscode/launch.json +0 -35
- package/lib/prisma/.vscode/settings.json +0 -6
- package/lib/prisma/Dockerfile.dev +0 -19
- package/lib/prisma/Dockerfile.prod +0 -19
- package/lib/prisma/Makefile +0 -46
- package/lib/prisma/docker-compose.yml +0 -51
- package/lib/prisma/ecosystem.config.js +0 -57
- package/lib/prisma/jest.config.js +0 -12
- package/lib/prisma/nginx.conf +0 -40
- package/lib/prisma/nodemon.json +0 -12
- package/lib/prisma/package.json +0 -84
- package/lib/prisma/src/app.ts +0 -81
- package/lib/prisma/src/config/index.ts +0 -5
- package/lib/prisma/src/controllers/auth.controller.ts +0 -44
- package/lib/prisma/src/controllers/users.controller.ts +0 -63
- package/lib/prisma/src/dtos/users.dto.ts +0 -20
- package/lib/prisma/src/exceptions/HttpException.ts +0 -10
- package/lib/prisma/src/http/auth.http +0 -27
- package/lib/prisma/src/http/users.http +0 -34
- package/lib/prisma/src/interfaces/auth.interface.ts +0 -15
- package/lib/prisma/src/interfaces/routes.interface.ts +0 -6
- package/lib/prisma/src/interfaces/users.interface.ts +0 -5
- package/lib/prisma/src/middlewares/auth.middleware.ts +0 -39
- package/lib/prisma/src/middlewares/error.middleware.ts +0 -15
- package/lib/prisma/src/middlewares/validation.middleware.ts +0 -27
- package/lib/prisma/src/prisma/migrations/20210314081925_initial/migration.sql +0 -9
- package/lib/prisma/src/prisma/migrations/migration_lock.toml +0 -3
- package/lib/prisma/src/prisma/schema.prisma +0 -17
- package/lib/prisma/src/routes/auth.route.ts +0 -22
- package/lib/prisma/src/routes/users.route.ts +0 -23
- package/lib/prisma/src/server.ts +0 -10
- package/lib/prisma/src/services/auth.service.ts +0 -56
- package/lib/prisma/src/services/users.service.ts +0 -49
- package/lib/prisma/src/test/auth.test.ts +0 -81
- package/lib/prisma/src/test/index.test.ts +0 -18
- package/lib/prisma/src/test/users.test.ts +0 -134
- package/lib/prisma/src/utils/logger.ts +0 -65
- package/lib/prisma/src/utils/validateEnv.ts +0 -8
- package/lib/prisma/swagger.yaml +0 -123
- package/lib/prisma/tsconfig.json +0 -38
- package/lib/routing-controllers/.dockerignore +0 -18
- package/lib/routing-controllers/.editorconfig +0 -9
- package/lib/routing-controllers/.env.development.local +0 -13
- package/lib/routing-controllers/.env.production.local +0 -13
- package/lib/routing-controllers/.env.test.local +0 -13
- package/lib/routing-controllers/.eslintignore +0 -1
- package/lib/routing-controllers/.eslintrc +0 -18
- package/lib/routing-controllers/.huskyrc +0 -5
- package/lib/routing-controllers/.lintstagedrc.json +0 -5
- package/lib/routing-controllers/.prettierrc +0 -8
- package/lib/routing-controllers/.swcrc +0 -38
- package/lib/routing-controllers/.vscode/launch.json +0 -35
- package/lib/routing-controllers/.vscode/settings.json +0 -6
- package/lib/routing-controllers/Dockerfile.dev +0 -19
- package/lib/routing-controllers/Dockerfile.prod +0 -19
- package/lib/routing-controllers/Makefile +0 -42
- package/lib/routing-controllers/docker-compose.yml +0 -35
- package/lib/routing-controllers/ecosystem.config.js +0 -57
- package/lib/routing-controllers/jest.config.js +0 -12
- package/lib/routing-controllers/nginx.conf +0 -40
- package/lib/routing-controllers/nodemon.json +0 -12
- package/lib/routing-controllers/package.json +0 -77
- package/lib/routing-controllers/src/app.ts +0 -101
- package/lib/routing-controllers/src/config/index.ts +0 -5
- package/lib/routing-controllers/src/controllers/auth.controller.ts +0 -41
- package/lib/routing-controllers/src/controllers/users.controller.ts +0 -51
- package/lib/routing-controllers/src/dtos/users.dto.ts +0 -20
- package/lib/routing-controllers/src/exceptions/HttpException.ts +0 -12
- package/lib/routing-controllers/src/http/auth.http +0 -27
- package/lib/routing-controllers/src/http/users.http +0 -34
- package/lib/routing-controllers/src/interfaces/auth.interface.ts +0 -15
- package/lib/routing-controllers/src/interfaces/users.interface.ts +0 -5
- package/lib/routing-controllers/src/middlewares/auth.middleware.ts +0 -38
- package/lib/routing-controllers/src/middlewares/error.middleware.ts +0 -15
- package/lib/routing-controllers/src/middlewares/validation.middleware.ts +0 -27
- package/lib/routing-controllers/src/models/users.model.ts +0 -9
- package/lib/routing-controllers/src/server.ts +0 -9
- package/lib/routing-controllers/src/services/auth.service.ts +0 -53
- package/lib/routing-controllers/src/services/users.service.ts +0 -52
- package/lib/routing-controllers/src/test/auth.test.ts +0 -49
- package/lib/routing-controllers/src/test/users.test.ts +0 -65
- package/lib/routing-controllers/src/utils/logger.ts +0 -65
- package/lib/routing-controllers/src/utils/validateEnv.ts +0 -8
- package/lib/routing-controllers/tsconfig.json +0 -38
- package/lib/sequelize/.dockerignore +0 -18
- package/lib/sequelize/.editorconfig +0 -9
- package/lib/sequelize/.env.development.local +0 -20
- package/lib/sequelize/.env.production.local +0 -20
- package/lib/sequelize/.env.test.local +0 -20
- package/lib/sequelize/.eslintignore +0 -1
- package/lib/sequelize/.eslintrc +0 -18
- package/lib/sequelize/.huskyrc +0 -5
- package/lib/sequelize/.lintstagedrc.json +0 -5
- package/lib/sequelize/.prettierrc +0 -8
- package/lib/sequelize/.sequelizerc +0 -8
- package/lib/sequelize/.swcrc +0 -40
- package/lib/sequelize/.vscode/launch.json +0 -35
- package/lib/sequelize/.vscode/settings.json +0 -6
- package/lib/sequelize/Dockerfile.dev +0 -23
- package/lib/sequelize/Dockerfile.prod +0 -23
- package/lib/sequelize/Makefile +0 -46
- package/lib/sequelize/docker-compose.yml +0 -55
- package/lib/sequelize/docker-entrypoint.sh +0 -5
- package/lib/sequelize/ecosystem.config.js +0 -57
- package/lib/sequelize/jest.config.js +0 -12
- package/lib/sequelize/nginx.conf +0 -40
- package/lib/sequelize/nodemon.json +0 -12
- package/lib/sequelize/package.json +0 -82
- package/lib/sequelize/src/app.ts +0 -87
- package/lib/sequelize/src/config/index.ts +0 -6
- package/lib/sequelize/src/config/sequelize-cli.js +0 -15
- package/lib/sequelize/src/controllers/auth.controller.ts +0 -45
- package/lib/sequelize/src/controllers/users.controller.ts +0 -64
- package/lib/sequelize/src/database/index.ts +0 -34
- package/lib/sequelize/src/database/migrations/.gitkeep +0 -0
- package/lib/sequelize/src/database/seeders/.gitkeep +0 -0
- package/lib/sequelize/src/dtos/users.dto.ts +0 -20
- package/lib/sequelize/src/exceptions/HttpException.ts +0 -10
- package/lib/sequelize/src/http/auth.http +0 -27
- package/lib/sequelize/src/http/users.http +0 -34
- package/lib/sequelize/src/interfaces/auth.interface.ts +0 -15
- package/lib/sequelize/src/interfaces/routes.interface.ts +0 -6
- package/lib/sequelize/src/interfaces/users.interface.ts +0 -5
- package/lib/sequelize/src/middlewares/auth.middleware.ts +0 -38
- package/lib/sequelize/src/middlewares/error.middleware.ts +0 -15
- package/lib/sequelize/src/middlewares/validation.middleware.ts +0 -27
- package/lib/sequelize/src/models/users.model.ts +0 -39
- package/lib/sequelize/src/routes/auth.route.ts +0 -21
- package/lib/sequelize/src/routes/users.route.ts +0 -23
- package/lib/sequelize/src/server.ts +0 -10
- package/lib/sequelize/src/services/auth.service.ts +0 -52
- package/lib/sequelize/src/services/users.service.ts +0 -50
- package/lib/sequelize/src/test/auth.test.ts +0 -71
- package/lib/sequelize/src/test/users.test.ts +0 -131
- package/lib/sequelize/src/utils/logger.ts +0 -65
- package/lib/sequelize/src/utils/validateEnv.ts +0 -8
- package/lib/sequelize/swagger.yaml +0 -123
- package/lib/sequelize/tsconfig.json +0 -40
- package/lib/starter.js +0 -262
- package/lib/typegoose/.dockerignore +0 -18
- package/lib/typegoose/.editorconfig +0 -9
- package/lib/typegoose/.env.development.local +0 -18
- package/lib/typegoose/.env.production.local +0 -18
- package/lib/typegoose/.env.test.local +0 -18
- package/lib/typegoose/.eslintignore +0 -1
- package/lib/typegoose/.eslintrc +0 -18
- package/lib/typegoose/.huskyrc +0 -5
- package/lib/typegoose/.lintstagedrc.json +0 -5
- package/lib/typegoose/.prettierrc +0 -8
- package/lib/typegoose/.swcrc +0 -40
- package/lib/typegoose/.vscode/launch.json +0 -35
- package/lib/typegoose/.vscode/settings.json +0 -6
- package/lib/typegoose/Dockerfile.dev +0 -19
- package/lib/typegoose/Dockerfile.prod +0 -19
- package/lib/typegoose/Makefile +0 -46
- package/lib/typegoose/docker-compose.yml +0 -55
- package/lib/typegoose/ecosystem.config.js +0 -57
- package/lib/typegoose/jest.config.js +0 -12
- package/lib/typegoose/nginx.conf +0 -40
- package/lib/typegoose/nodemon.json +0 -12
- package/lib/typegoose/package.json +0 -79
- package/lib/typegoose/src/app.ts +0 -90
- package/lib/typegoose/src/config/index.ts +0 -6
- package/lib/typegoose/src/controllers/auth.controller.ts +0 -44
- package/lib/typegoose/src/controllers/users.controller.ts +0 -63
- package/lib/typegoose/src/database/index.ts +0 -18
- package/lib/typegoose/src/dtos/users.dto.ts +0 -20
- package/lib/typegoose/src/exceptions/HttpException.ts +0 -10
- package/lib/typegoose/src/http/auth.http +0 -27
- package/lib/typegoose/src/http/users.http +0 -34
- package/lib/typegoose/src/interfaces/auth.interface.ts +0 -15
- package/lib/typegoose/src/interfaces/routes.interface.ts +0 -6
- package/lib/typegoose/src/interfaces/users.interface.ts +0 -5
- package/lib/typegoose/src/middlewares/auth.middleware.ts +0 -38
- package/lib/typegoose/src/middlewares/error.middleware.ts +0 -15
- package/lib/typegoose/src/middlewares/validation.middleware.ts +0 -27
- package/lib/typegoose/src/models/users.model.ts +0 -16
- package/lib/typegoose/src/routes/auth.route.ts +0 -21
- package/lib/typegoose/src/routes/users.route.ts +0 -23
- package/lib/typegoose/src/server.ts +0 -10
- package/lib/typegoose/src/services/auth.service.ts +0 -52
- package/lib/typegoose/src/services/users.service.ts +0 -55
- package/lib/typegoose/src/test/auth.test.ts +0 -83
- package/lib/typegoose/src/test/users.test.ts +0 -133
- package/lib/typegoose/src/utils/logger.ts +0 -65
- package/lib/typegoose/src/utils/validateEnv.ts +0 -8
- package/lib/typegoose/swagger.yaml +0 -120
- package/lib/typegoose/tsconfig.json +0 -40
- package/lib/typeorm/.dockerignore +0 -18
- package/lib/typeorm/.editorconfig +0 -9
- package/lib/typeorm/.env.development.local +0 -20
- package/lib/typeorm/.env.production.local +0 -20
- package/lib/typeorm/.env.test.local +0 -20
- package/lib/typeorm/.eslintignore +0 -1
- package/lib/typeorm/.eslintrc +0 -18
- package/lib/typeorm/.huskyrc +0 -5
- package/lib/typeorm/.lintstagedrc.json +0 -5
- package/lib/typeorm/.prettierrc +0 -8
- package/lib/typeorm/.swcrc +0 -40
- package/lib/typeorm/.vscode/launch.json +0 -35
- package/lib/typeorm/.vscode/settings.json +0 -6
- package/lib/typeorm/Dockerfile.dev +0 -19
- package/lib/typeorm/Dockerfile.prod +0 -19
- package/lib/typeorm/Makefile +0 -46
- package/lib/typeorm/docker-compose.yml +0 -57
- package/lib/typeorm/ecosystem.config.js +0 -57
- package/lib/typeorm/jest.config.js +0 -12
- package/lib/typeorm/nginx.conf +0 -40
- package/lib/typeorm/nodemon.json +0 -12
- package/lib/typeorm/package.json +0 -78
- package/lib/typeorm/src/app.ts +0 -87
- package/lib/typeorm/src/config/index.ts +0 -6
- package/lib/typeorm/src/controllers/auth.controller.ts +0 -44
- package/lib/typeorm/src/controllers/users.controller.ts +0 -63
- package/lib/typeorm/src/database/index.ts +0 -26
- package/lib/typeorm/src/database/migrations/.gitkeep +0 -0
- package/lib/typeorm/src/dtos/users.dto.ts +0 -20
- package/lib/typeorm/src/entities/users.entity.ts +0 -26
- package/lib/typeorm/src/exceptions/HttpException.ts +0 -10
- package/lib/typeorm/src/http/auth.http +0 -27
- package/lib/typeorm/src/http/users.http +0 -34
- package/lib/typeorm/src/interfaces/auth.interface.ts +0 -15
- package/lib/typeorm/src/interfaces/routes.interface.ts +0 -6
- package/lib/typeorm/src/interfaces/users.interface.ts +0 -5
- package/lib/typeorm/src/middlewares/auth.middleware.ts +0 -38
- package/lib/typeorm/src/middlewares/error.middleware.ts +0 -15
- package/lib/typeorm/src/middlewares/validation.middleware.ts +0 -27
- package/lib/typeorm/src/routes/auth.route.ts +0 -21
- package/lib/typeorm/src/routes/users.route.ts +0 -23
- package/lib/typeorm/src/server.ts +0 -10
- package/lib/typeorm/src/services/auth.service.ts +0 -54
- package/lib/typeorm/src/services/users.service.ts +0 -51
- package/lib/typeorm/src/test/auth.test.ts +0 -75
- package/lib/typeorm/src/test/users.test.ts +0 -136
- package/lib/typeorm/src/utils/logger.ts +0 -65
- package/lib/typeorm/src/utils/validateEnv.ts +0 -8
- package/lib/typeorm/swagger.yaml +0 -123
- /package/{lib → templates}/default/src/interfaces/routes.interface.ts +0 -0
package/lib/typegoose/Makefile
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# app name should be overridden.
|
|
2
|
-
# ex) production-stage: make build APP_NAME=<APP_NAME>
|
|
3
|
-
# ex) development-stage: make build-dev APP_NAME=<APP_NAME>
|
|
4
|
-
|
|
5
|
-
SHELL := /bin/bash
|
|
6
|
-
|
|
7
|
-
APP_NAME = typescript-express
|
|
8
|
-
APP_NAME := $(APP_NAME)
|
|
9
|
-
|
|
10
|
-
.PHONY: help start clean db test
|
|
11
|
-
|
|
12
|
-
help:
|
|
13
|
-
@grep -E '^[1-9a-zA-Z_-]+:.*?## .*$$|(^#--)' $(MAKEFILE_LIST) \
|
|
14
|
-
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m %-43s\033[0m %s\n", $$1, $$2}' \
|
|
15
|
-
| sed -e 's/\[32m #-- /[33m/'
|
|
16
|
-
|
|
17
|
-
#-- Docker
|
|
18
|
-
up: ## Up the container images
|
|
19
|
-
docker-compose up -d
|
|
20
|
-
|
|
21
|
-
down: ## Down the container images
|
|
22
|
-
docker-compose down
|
|
23
|
-
|
|
24
|
-
build: ## Build the container image - Production
|
|
25
|
-
docker build -t ${APP_NAME}\
|
|
26
|
-
-f Dockerfile.prod .
|
|
27
|
-
|
|
28
|
-
build-dev: ## Build the container image - Development
|
|
29
|
-
docker build -t ${APP_NAME}\
|
|
30
|
-
-f Dockerfile.dev .
|
|
31
|
-
|
|
32
|
-
run: ## Run the container image
|
|
33
|
-
docker run -d -it -p 3000:3000 ${APP_NAME}
|
|
34
|
-
|
|
35
|
-
pause: ## Pause the containers
|
|
36
|
-
docker container rm -f ${APP_NAME}
|
|
37
|
-
|
|
38
|
-
clean: ## Clean the images
|
|
39
|
-
docker rmi -f ${APP_NAME}
|
|
40
|
-
|
|
41
|
-
remove: ## Remove the volumes
|
|
42
|
-
docker volume rm -f ${APP_NAME}
|
|
43
|
-
|
|
44
|
-
#-- Database
|
|
45
|
-
db: ## Start the local database MongoDB
|
|
46
|
-
docker-compose up -d mongo
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
version: "3.9"
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
proxy:
|
|
5
|
-
container_name: proxy
|
|
6
|
-
image: nginx:alpine
|
|
7
|
-
ports:
|
|
8
|
-
- "80:80"
|
|
9
|
-
volumes:
|
|
10
|
-
- ./nginx.conf:/etc/nginx/nginx.conf
|
|
11
|
-
restart: "unless-stopped"
|
|
12
|
-
networks:
|
|
13
|
-
- backend
|
|
14
|
-
|
|
15
|
-
server:
|
|
16
|
-
container_name: server
|
|
17
|
-
build:
|
|
18
|
-
context: ./
|
|
19
|
-
dockerfile: Dockerfile.dev
|
|
20
|
-
ports:
|
|
21
|
-
- "3000:3000"
|
|
22
|
-
environment:
|
|
23
|
-
DB_HOST: localhost
|
|
24
|
-
DB_PORT: 27017
|
|
25
|
-
DB_DATABASE: dev
|
|
26
|
-
volumes:
|
|
27
|
-
- ./:/app
|
|
28
|
-
- /app/node_modules
|
|
29
|
-
restart: "unless-stopped"
|
|
30
|
-
networks:
|
|
31
|
-
- backend
|
|
32
|
-
links:
|
|
33
|
-
- mongo
|
|
34
|
-
depends_on:
|
|
35
|
-
- mongo
|
|
36
|
-
|
|
37
|
-
mongo:
|
|
38
|
-
container_name: mongo
|
|
39
|
-
image: mongo
|
|
40
|
-
ports:
|
|
41
|
-
- "27017:27017"
|
|
42
|
-
environment:
|
|
43
|
-
DB_HOST: localhost
|
|
44
|
-
DB_PORT: 27017
|
|
45
|
-
DB_DATABASE: dev
|
|
46
|
-
networks:
|
|
47
|
-
- backend
|
|
48
|
-
|
|
49
|
-
networks:
|
|
50
|
-
backend:
|
|
51
|
-
driver: bridge
|
|
52
|
-
|
|
53
|
-
volumes:
|
|
54
|
-
data:
|
|
55
|
-
driver: local
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description pm2 configuration file.
|
|
3
|
-
* @example
|
|
4
|
-
* production mode :: pm2 start ecosystem.config.js --only prod
|
|
5
|
-
* development mode :: pm2 start ecosystem.config.js --only dev
|
|
6
|
-
*/
|
|
7
|
-
module.exports = {
|
|
8
|
-
apps: [
|
|
9
|
-
{
|
|
10
|
-
name: 'prod', // pm2 start App name
|
|
11
|
-
script: 'dist/server.js',
|
|
12
|
-
exec_mode: 'cluster', // 'cluster' or 'fork'
|
|
13
|
-
instance_var: 'INSTANCE_ID', // instance variable
|
|
14
|
-
instances: 2, // pm2 instance count
|
|
15
|
-
autorestart: true, // auto restart if process crash
|
|
16
|
-
watch: false, // files change automatic restart
|
|
17
|
-
ignore_watch: ['node_modules', 'logs'], // ignore files change
|
|
18
|
-
max_memory_restart: '1G', // restart if process use more than 1G memory
|
|
19
|
-
merge_logs: true, // if true, stdout and stderr will be merged and sent to pm2 log
|
|
20
|
-
output: './logs/access.log', // pm2 log file
|
|
21
|
-
error: './logs/error.log', // pm2 error log file
|
|
22
|
-
env: { // environment variable
|
|
23
|
-
PORT: 3000,
|
|
24
|
-
NODE_ENV: 'production',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'dev', // pm2 start App name
|
|
29
|
-
script: 'ts-node', // ts-node
|
|
30
|
-
args: '-r tsconfig-paths/register --transpile-only src/server.ts', // ts-node args
|
|
31
|
-
exec_mode: 'cluster', // 'cluster' or 'fork'
|
|
32
|
-
instance_var: 'INSTANCE_ID', // instance variable
|
|
33
|
-
instances: 2, // pm2 instance count
|
|
34
|
-
autorestart: true, // auto restart if process crash
|
|
35
|
-
watch: false, // files change automatic restart
|
|
36
|
-
ignore_watch: ['node_modules', 'logs'], // ignore files change
|
|
37
|
-
max_memory_restart: '1G', // restart if process use more than 1G memory
|
|
38
|
-
merge_logs: true, // if true, stdout and stderr will be merged and sent to pm2 log
|
|
39
|
-
output: './logs/access.log', // pm2 log file
|
|
40
|
-
error: './logs/error.log', // pm2 error log file
|
|
41
|
-
env: { // environment variable
|
|
42
|
-
PORT: 3000,
|
|
43
|
-
NODE_ENV: 'development',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
deploy: {
|
|
48
|
-
production: {
|
|
49
|
-
user: 'user',
|
|
50
|
-
host: '0.0.0.0',
|
|
51
|
-
ref: 'origin/master',
|
|
52
|
-
repo: 'git@github.com:repo.git',
|
|
53
|
-
path: 'dist/server.js',
|
|
54
|
-
'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --only prod',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const { pathsToModuleNameMapper } = require('ts-jest');
|
|
2
|
-
const { compilerOptions } = require('./tsconfig.json');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
preset: 'ts-jest',
|
|
6
|
-
testEnvironment: 'node',
|
|
7
|
-
roots: ['<rootDir>/src'],
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.tsx?$': 'ts-jest',
|
|
10
|
-
},
|
|
11
|
-
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src' }),
|
|
12
|
-
};
|
package/lib/typegoose/nginx.conf
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
user nginx;
|
|
2
|
-
worker_processes 1;
|
|
3
|
-
|
|
4
|
-
error_log /var/log/nginx/error.log warn;
|
|
5
|
-
pid /var/run/nginx.pid;
|
|
6
|
-
|
|
7
|
-
events {
|
|
8
|
-
worker_connections 1024;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
http {
|
|
12
|
-
include /etc/nginx/mime.types;
|
|
13
|
-
default_type application/octet-stream;
|
|
14
|
-
|
|
15
|
-
upstream api-server {
|
|
16
|
-
server server:3000;
|
|
17
|
-
keepalive 100;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
server {
|
|
21
|
-
listen 80;
|
|
22
|
-
server_name localhost;
|
|
23
|
-
|
|
24
|
-
location / {
|
|
25
|
-
proxy_http_version 1.1;
|
|
26
|
-
proxy_pass http://api-server;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
32
|
-
'$status $body_bytes_sent "$http_referer" '
|
|
33
|
-
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
34
|
-
|
|
35
|
-
access_log /var/log/nginx/access.log main;
|
|
36
|
-
|
|
37
|
-
sendfile on;
|
|
38
|
-
keepalive_timeout 65;
|
|
39
|
-
include /etc/nginx/conf.d/*.conf;
|
|
40
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "typescript-express-starter",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "TypeScript + Typegoose + MongoDB + Express API Server",
|
|
5
|
-
"author": "",
|
|
6
|
-
"license": "ISC",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "npm run build && cross-env NODE_ENV=production node dist/server.js",
|
|
9
|
-
"dev": "cross-env NODE_ENV=development nodemon",
|
|
10
|
-
"build": "swc src -d dist --source-maps --copy-files",
|
|
11
|
-
"build:tsc": "tsc && tsc-alias",
|
|
12
|
-
"test": "jest --forceExit --detectOpenHandles",
|
|
13
|
-
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
|
|
14
|
-
"lint:fix": "npm run lint -- --fix",
|
|
15
|
-
"deploy:prod": "npm run build && pm2 start ecosystem.config.js --only prod",
|
|
16
|
-
"deploy:dev": "pm2 start ecosystem.config.js --only dev"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@typegoose/typegoose": "^9.10.1",
|
|
20
|
-
"bcrypt": "^5.0.1",
|
|
21
|
-
"class-transformer": "^0.5.1",
|
|
22
|
-
"class-validator": "^0.13.2",
|
|
23
|
-
"compression": "^1.7.4",
|
|
24
|
-
"cookie-parser": "^1.4.6",
|
|
25
|
-
"cors": "^2.8.5",
|
|
26
|
-
"dotenv": "^16.0.1",
|
|
27
|
-
"envalid": "^7.3.1",
|
|
28
|
-
"express": "^4.18.1",
|
|
29
|
-
"helmet": "^5.1.1",
|
|
30
|
-
"hpp": "^0.2.3",
|
|
31
|
-
"jsonwebtoken": "^8.5.1",
|
|
32
|
-
"mongoose": "^6.3.2",
|
|
33
|
-
"morgan": "^1.10.0",
|
|
34
|
-
"reflect-metadata": "^0.1.13",
|
|
35
|
-
"swagger-jsdoc": "^6.2.1",
|
|
36
|
-
"swagger-ui-express": "^4.5.0",
|
|
37
|
-
"typedi": "^0.10.0",
|
|
38
|
-
"winston": "^3.8.1",
|
|
39
|
-
"winston-daily-rotate-file": "^4.7.1"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@swc/cli": "^0.1.57",
|
|
43
|
-
"@swc/core": "^1.2.220",
|
|
44
|
-
"@types/bcrypt": "^5.0.0",
|
|
45
|
-
"@types/compression": "^1.7.2",
|
|
46
|
-
"@types/cookie-parser": "^1.4.3",
|
|
47
|
-
"@types/cors": "^2.8.12",
|
|
48
|
-
"@types/express": "^4.17.13",
|
|
49
|
-
"@types/hpp": "^0.2.2",
|
|
50
|
-
"@types/jest": "^28.1.6",
|
|
51
|
-
"@types/jsonwebtoken": "^8.5.8",
|
|
52
|
-
"@types/mongoose": "^5.10.1",
|
|
53
|
-
"@types/morgan": "^1.9.3",
|
|
54
|
-
"@types/node": "^17.0.45",
|
|
55
|
-
"@types/supertest": "^2.0.12",
|
|
56
|
-
"@types/swagger-jsdoc": "^6.0.1",
|
|
57
|
-
"@types/swagger-ui-express": "^4.1.3",
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^5.29.0",
|
|
59
|
-
"@typescript-eslint/parser": "^5.29.0",
|
|
60
|
-
"cross-env": "^7.0.3",
|
|
61
|
-
"eslint": "^8.20.0",
|
|
62
|
-
"eslint-config-prettier": "^8.5.0",
|
|
63
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
64
|
-
"husky": "^8.0.1",
|
|
65
|
-
"jest": "^28.1.1",
|
|
66
|
-
"lint-staged": "^13.0.3",
|
|
67
|
-
"node-config": "^0.0.2",
|
|
68
|
-
"node-gyp": "^9.1.0",
|
|
69
|
-
"nodemon": "^2.0.19",
|
|
70
|
-
"pm2": "^5.2.0",
|
|
71
|
-
"prettier": "^2.7.1",
|
|
72
|
-
"supertest": "^6.2.4",
|
|
73
|
-
"ts-jest": "^28.0.7",
|
|
74
|
-
"ts-node": "^10.9.1",
|
|
75
|
-
"tsc-alias": "^1.7.0",
|
|
76
|
-
"tsconfig-paths": "^4.0.0",
|
|
77
|
-
"typescript": "^4.7.4"
|
|
78
|
-
}
|
|
79
|
-
}
|
package/lib/typegoose/src/app.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import compression from 'compression';
|
|
3
|
-
import cookieParser from 'cookie-parser';
|
|
4
|
-
import cors from 'cors';
|
|
5
|
-
import express from 'express';
|
|
6
|
-
import helmet from 'helmet';
|
|
7
|
-
import hpp from 'hpp';
|
|
8
|
-
import morgan from 'morgan';
|
|
9
|
-
|
|
10
|
-
import swaggerJSDoc from 'swagger-jsdoc';
|
|
11
|
-
import swaggerUi from 'swagger-ui-express';
|
|
12
|
-
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
|
|
13
|
-
import { dbConnection } from '@database';
|
|
14
|
-
import { Routes } from '@interfaces/routes.interface';
|
|
15
|
-
import { ErrorMiddleware } from '@middlewares/error.middleware';
|
|
16
|
-
import { logger, stream } from '@utils/logger';
|
|
17
|
-
|
|
18
|
-
class App {
|
|
19
|
-
public app: express.Application;
|
|
20
|
-
public env: string;
|
|
21
|
-
public port: string | number;
|
|
22
|
-
|
|
23
|
-
constructor(routes: Routes[]) {
|
|
24
|
-
this.app = express();
|
|
25
|
-
this.env = NODE_ENV || 'development';
|
|
26
|
-
this.port = PORT || 3000;
|
|
27
|
-
|
|
28
|
-
this.connectToDatabase();
|
|
29
|
-
this.initializeMiddlewares();
|
|
30
|
-
this.initializeRoutes(routes);
|
|
31
|
-
this.initializeSwagger();
|
|
32
|
-
this.initializeErrorHandling();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public listen() {
|
|
36
|
-
this.app.listen(this.port, () => {
|
|
37
|
-
logger.info(`=================================`);
|
|
38
|
-
logger.info(`======= ENV: ${this.env} =======`);
|
|
39
|
-
logger.info(`🚀 App listening on the port ${this.port}`);
|
|
40
|
-
logger.info(`=================================`);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public getServer() {
|
|
45
|
-
return this.app;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private async connectToDatabase() {
|
|
49
|
-
await dbConnection();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private initializeMiddlewares() {
|
|
53
|
-
this.app.use(morgan(LOG_FORMAT, { stream }));
|
|
54
|
-
this.app.use(cors({ origin: ORIGIN, credentials: CREDENTIALS }));
|
|
55
|
-
this.app.use(hpp());
|
|
56
|
-
this.app.use(helmet());
|
|
57
|
-
this.app.use(compression());
|
|
58
|
-
this.app.use(express.json());
|
|
59
|
-
this.app.use(express.urlencoded({ extended: true }));
|
|
60
|
-
this.app.use(cookieParser());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private initializeRoutes(routes: Routes[]) {
|
|
64
|
-
routes.forEach(route => {
|
|
65
|
-
this.app.use('/', route.router);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private initializeSwagger() {
|
|
70
|
-
const options = {
|
|
71
|
-
swaggerDefinition: {
|
|
72
|
-
info: {
|
|
73
|
-
title: 'REST API',
|
|
74
|
-
version: '1.0.0',
|
|
75
|
-
description: 'Example docs',
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
apis: ['swagger.yaml'],
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const specs = swaggerJSDoc(options);
|
|
82
|
-
this.app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private initializeErrorHandling() {
|
|
86
|
-
this.app.use(ErrorMiddleware);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default App;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { config } from 'dotenv';
|
|
2
|
-
config({ path: `.env.${process.env.NODE_ENV || 'development'}.local` });
|
|
3
|
-
|
|
4
|
-
export const CREDENTIALS = process.env.CREDENTIALS === 'true';
|
|
5
|
-
export const { NODE_ENV, PORT, SECRET_KEY, LOG_FORMAT, LOG_DIR, ORIGIN } = process.env;
|
|
6
|
-
export const { DB_HOST, DB_PORT, DB_DATABASE } = process.env;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { Container } from 'typedi';
|
|
3
|
-
import { RequestWithUser } from '@interfaces/auth.interface';
|
|
4
|
-
import { User } from '@interfaces/users.interface';
|
|
5
|
-
import { AuthService } from '@services/auth.service';
|
|
6
|
-
|
|
7
|
-
export class AuthController {
|
|
8
|
-
public auth = Container.get(AuthService);
|
|
9
|
-
|
|
10
|
-
public signUp = async (req: Request, res: Response, next: NextFunction) => {
|
|
11
|
-
try {
|
|
12
|
-
const userData: User = req.body;
|
|
13
|
-
const signUpUserData: User = await this.auth.signup(userData);
|
|
14
|
-
|
|
15
|
-
res.status(201).json({ data: signUpUserData, message: 'signup' });
|
|
16
|
-
} catch (error) {
|
|
17
|
-
next(error);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
public logIn = async (req: Request, res: Response, next: NextFunction) => {
|
|
22
|
-
try {
|
|
23
|
-
const userData: User = req.body;
|
|
24
|
-
const { cookie, findUser } = await this.auth.login(userData);
|
|
25
|
-
|
|
26
|
-
res.setHeader('Set-Cookie', [cookie]);
|
|
27
|
-
res.status(200).json({ data: findUser, message: 'login' });
|
|
28
|
-
} catch (error) {
|
|
29
|
-
next(error);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
public logOut = async (req: RequestWithUser, res: Response, next: NextFunction) => {
|
|
34
|
-
try {
|
|
35
|
-
const userData: User = req.user;
|
|
36
|
-
const logOutUserData: User = await this.auth.logout(userData);
|
|
37
|
-
|
|
38
|
-
res.setHeader('Set-Cookie', ['Authorization=; Max-age=0']);
|
|
39
|
-
res.status(200).json({ data: logOutUserData, message: 'logout' });
|
|
40
|
-
} catch (error) {
|
|
41
|
-
next(error);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { Container } from 'typedi';
|
|
3
|
-
import { User } from '@interfaces/users.interface';
|
|
4
|
-
import { UserService } from '@services/users.service';
|
|
5
|
-
|
|
6
|
-
export class UserController {
|
|
7
|
-
public user = Container.get(UserService);
|
|
8
|
-
|
|
9
|
-
public getUsers = async (req: Request, res: Response, next: NextFunction) => {
|
|
10
|
-
try {
|
|
11
|
-
const findAllUsersData: User[] = await this.user.findAllUser();
|
|
12
|
-
|
|
13
|
-
res.status(200).json({ data: findAllUsersData, message: 'findAll' });
|
|
14
|
-
} catch (error) {
|
|
15
|
-
next(error);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
public getUserById = async (req: Request, res: Response, next: NextFunction) => {
|
|
20
|
-
try {
|
|
21
|
-
const userId: string = req.params.id;
|
|
22
|
-
const findOneUserData: User = await this.user.findUserById(userId);
|
|
23
|
-
|
|
24
|
-
res.status(200).json({ data: findOneUserData, message: 'findOne' });
|
|
25
|
-
} catch (error) {
|
|
26
|
-
next(error);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
public createUser = async (req: Request, res: Response, next: NextFunction) => {
|
|
31
|
-
try {
|
|
32
|
-
const userData: User = req.body;
|
|
33
|
-
const createUserData: User = await this.user.createUser(userData);
|
|
34
|
-
|
|
35
|
-
res.status(201).json({ data: createUserData, message: 'created' });
|
|
36
|
-
} catch (error) {
|
|
37
|
-
next(error);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
public updateUser = async (req: Request, res: Response, next: NextFunction) => {
|
|
42
|
-
try {
|
|
43
|
-
const userId: string = req.params.id;
|
|
44
|
-
const userData: User = req.body;
|
|
45
|
-
const updateUserData: User = await this.user.updateUser(userId, userData);
|
|
46
|
-
|
|
47
|
-
res.status(200).json({ data: updateUserData, message: 'updated' });
|
|
48
|
-
} catch (error) {
|
|
49
|
-
next(error);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
public deleteUser = async (req: Request, res: Response, next: NextFunction) => {
|
|
54
|
-
try {
|
|
55
|
-
const userId: string = req.params.id;
|
|
56
|
-
const deleteUserData: User = await this.user.deleteUser(userId);
|
|
57
|
-
|
|
58
|
-
res.status(200).json({ data: deleteUserData, message: 'deleted' });
|
|
59
|
-
} catch (error) {
|
|
60
|
-
next(error);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { connect, set } from 'mongoose';
|
|
2
|
-
import { NODE_ENV, DB_HOST, DB_PORT, DB_DATABASE } from '@config';
|
|
3
|
-
|
|
4
|
-
export const dbConnection = async () => {
|
|
5
|
-
const dbConfing = {
|
|
6
|
-
url: `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`,
|
|
7
|
-
options: {
|
|
8
|
-
useNewUrlParser: true,
|
|
9
|
-
useUnifiedTopology: true
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
if (NODE_ENV !== 'production') {
|
|
14
|
-
set('debug', true);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
await connect(dbConfing);
|
|
18
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IsEmail, IsString, IsNotEmpty, MinLength, MaxLength } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class CreateUserDto {
|
|
4
|
-
@IsEmail()
|
|
5
|
-
public email: string;
|
|
6
|
-
|
|
7
|
-
@IsString()
|
|
8
|
-
@IsNotEmpty()
|
|
9
|
-
@MinLength(9)
|
|
10
|
-
@MaxLength(32)
|
|
11
|
-
public password: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class UpdateUserDto {
|
|
15
|
-
@IsString()
|
|
16
|
-
@IsNotEmpty()
|
|
17
|
-
@MinLength(9)
|
|
18
|
-
@MaxLength(32)
|
|
19
|
-
public password: string;
|
|
20
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# baseURL
|
|
2
|
-
@baseURL = http://localhost:3000
|
|
3
|
-
|
|
4
|
-
###
|
|
5
|
-
# User Signup
|
|
6
|
-
POST {{ baseURL }}/signup
|
|
7
|
-
Content-Type: application/json
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
"email": "example@email.com",
|
|
11
|
-
"password": "password"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
###
|
|
15
|
-
# User Login
|
|
16
|
-
POST {{ baseURL }}/login
|
|
17
|
-
Content-Type: application/json
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
"email": "example@email.com",
|
|
21
|
-
"password": "password"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
###
|
|
25
|
-
# User Logout
|
|
26
|
-
POST {{ baseURL }}/logout
|
|
27
|
-
Content-Type: application/json
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# baseURL
|
|
2
|
-
@baseURL = http://localhost:3000
|
|
3
|
-
|
|
4
|
-
###
|
|
5
|
-
# Find All Users
|
|
6
|
-
GET {{ baseURL }}/users
|
|
7
|
-
|
|
8
|
-
###
|
|
9
|
-
# Find User By Id
|
|
10
|
-
GET {{ baseURL }}/users/1
|
|
11
|
-
|
|
12
|
-
###
|
|
13
|
-
# Create User
|
|
14
|
-
POST {{ baseURL }}/users
|
|
15
|
-
Content-Type: application/json
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
"email": "example@email.com",
|
|
19
|
-
"password": "password"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
###
|
|
23
|
-
# Modify User By Id
|
|
24
|
-
PUT {{ baseURL }}/users/1
|
|
25
|
-
Content-Type: application/json
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
"email": "example@email.com",
|
|
29
|
-
"password": "password"
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
###
|
|
33
|
-
# Delete User By Id
|
|
34
|
-
DELETE {{ baseURL }}/users/1
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Request } from 'express';
|
|
2
|
-
import { User } from '@interfaces/users.interface';
|
|
3
|
-
|
|
4
|
-
export interface DataStoredInToken {
|
|
5
|
-
_id: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface TokenData {
|
|
9
|
-
token: string;
|
|
10
|
-
expiresIn: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface RequestWithUser extends Request {
|
|
14
|
-
user: User;
|
|
15
|
-
}
|