Giter Site home page Giter Site logo

vivify-ideas / nestjs-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
596.0 596.0 90.0 1.63 MB

NestJS Boilerplate 😻(Authentication, TypeORM, Configuration, Swagger)

License: MIT License

TypeScript 71.50% JavaScript 22.73% Dockerfile 0.75% Shell 5.02%
boilerplate nestjs restful-api swagger typescript

nestjs-boilerplate's People

Contributors

dependabot[bot] avatar fsschmitt avatar jovananov avatar miljanic avatar nikolasp avatar vivifyideas 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nestjs-boilerplate's Issues

Help with building

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?

error while installing project

./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

SyntaxError: Unexpected token const

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)`

Switch to `nest-typed-config` for configuration

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.

request /api/auth/me response "401 Unauthorized"

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

Error on test

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.

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.