vivify-ideas / nestjs-boilerplate Goto Github PK
View Code? Open in Web Editor NEWNestJS Boilerplate 😻(Authentication, TypeORM, Configuration, Swagger)
License: MIT License
NestJS Boilerplate 😻(Authentication, TypeORM, Configuration, Swagger)
License: MIT License
Hey,
Great job making this boilerplate, I want to use it on a personal project. However, I am encountering some issues running start:prod ( 'module/config' was not found ) - maybe some issues with the tsconfig file.
Any suggestions on how to use this in a prod env?
./init
[2021-06-20T14:25:37+0300]: Looks like both docker and docker-compose are installed, everything looks good.
[2021-06-20T14:25:37+0300]: Copying .env.example -> .env
[2021-06-20T14:25:37+0300]: Starting docker-compose stack if not already started..
Traceback (most recent call last):
File "urllib3/connectionpool.py", line 670, in urlopen
File "urllib3/connectionpool.py", line 392, in _make_request
File "http/client.py", line 1255, in request
File "http/client.py", line 1301, in _send_request
File "http/client.py", line 1250, in endheaders
File "http/client.py", line 1010, in _send_output
File "http/client.py", line 950, in send
File "docker/transport/unixconn.py", line 43, in connect
FileNotFoundError: [Errno 2] No such file or directory
When I run "npm run start:prod" the following error message appears:
`
(function (exports, require, module, __filename, __dirname) { declare const _default: {
^^^^^
SyntaxError: Unexpected token const
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)`
Nest-typed-config
is a module which enables defining config schema like request DTOs, and it supports reading configuration from environment variables, local files or remote configuration center.
In this boilerplate, three types of configurations are included: App, JWT and DB, which can be defined in a local toml
file for better organization:
# .env.toml
[App]
env = 'dev'
url = 'http://localhost'
[JWT]
secretKey = 'uAsBw6WxqD'
expirationTime = 3600
[DB]
type = 'mariadb'
username = 'nest'
password = 'nest'
host = 'db'
port = 3306
database = 'nest'
sync = false
More importantly, nest-typed-config
provides type-safe configurations, for example in app.module.ts
:
TypeOrmModule.forRootAsync({
// DBConfig is defined in config schema, and automatically injected
useFactory: (dbConfig: DBConfig) => {
return {
...dbConfig,
entities: [__dirname + './../**/**.entity{.ts,.js}'],
synchronize: dbConfig.sync,
}; // No type casting is required
},
})
Please let me know your thoughts, and I can open a pull request if this sounds good.
When runnig docker-compose up -d
the ngnix container is created but I get this error
/docker-entrypoint.sh: exec: line 38: /entrypoint-nginx.sh: not found
I run command yarn test:e2e
and got it:
Error: Can't find a root directory while resolving a config file path.
Provided path to resolve: ./test/jest-e2e.json
...
how to handle migrations?
request /api/auth/me response "401 Unauthorized"
but i already set header “Authorization" token for login response
my curl
curl -X GET "http://localhost:3000/api/auth/me" -H "accept: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTY4NTU5MzE4LCJleHAiOjE1Njg1NjI5MTh9.Irmkw2p2I_MiLcAxEqTpIR0GBhaDFbSYF3P4-ew5XEM"
but response "401 Unauthorized"
I hope to get a reply
Thank you
When I run npm test on default procject I get [ExceptionHandler] In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used. Otherwise, passport won't work correctly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.