GithubHelp home page GithubHelp logo

scopsy / node-typescript-starter Goto Github PK

View Code? Open in Web Editor NEW
49.0 9.0 11.0 172 KB

A modern nodejs api boilerplate with typescript

License: MIT License

TypeScript 100.00%
nodejs boilerplate-node starter-kit typescript javascript

node-typescript-starter's Introduction

Node Api Starter

Dependency Status

A starter for Node.js web api's.

Features

  • ts-express-decorator
  • Local authentication using Email and Password
  • Facebook authentication for client side sdk integration
  • JWT token authentication
  • Typescript
  • Swagger documentation
  • class-validator for validating controller json input
  • Scalable design
  • ES next features

Prerequisites

Getting Started

# Get the latest snapshot
git clone --depth=1 https://github.com/scopsy/node-typescript-starter.git projectname

cd projectname
rm -rf !$/.git

npm install

# start your app
npm start

node-typescript-starter's People

Contributors

combarnea avatar scopsy 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-typescript-starter's Issues

TypeError: Cannot read property 'get' of undefined

Hey guys could we get this starter updated? im trying to update to tsed but im failing hard...

TypeError: Cannot read property 'get' of undefined
at new ConverterService (/Users/milewski/Code/backend/node_modules/@tsed/src/common/converters/services/ConverterService.ts:21:53)
at Function.invoke (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:277:16)
at registry.forEach.provider (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:359:53)
at Map.forEach (<anonymous>)
at Registry.forEach (/Users/milewski/Code/backend/node_modules/@tsed/src/core/class/Registry.ts:140:19)
at Function.buildRegistry (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:357:18)
at Function.<anonymous> (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:443:14)
at Generator.next (<anonymous>)
at /Users/milewski/Code/backend/node_modules/tslib/tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/milewski/Code/backend/node_modules/tslib/tslib.js:103:16)
at Function.load (/Users/milewski/Code/backend/node_modules/@tsed/common/lib/di/services/InjectorService.js:350:24)
at InjectorService.<anonymous> (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:209:32)
at Generator.next (<anonymous>)
at /Users/milewski/Code/backend/node_modules/tslib/tslib.js:107:75
at new Promise (<anonymous>)
(node:2952) DeprecationWarning: Use registerFactory() util instead of
(node:2952) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at new ConverterService (/Users/milewski/Code/backend/node_modules/@tsed/src/common/converters/services/ConverterService.ts:21:53)
at Function.invoke (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:277:16)
at registry.forEach.provider (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:359:53)
at Map.forEach (<anonymous>)
at Registry.forEach (/Users/milewski/Code/backend/node_modules/@tsed/src/core/class/Registry.ts:140:19)
at Function.buildRegistry (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:357:18)
at Function.<anonymous> (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:443:14)
at Generator.next (<anonymous>)
at /Users/milewski/Code/backend/node_modules/tslib/tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/milewski/Code/backend/node_modules/tslib/tslib.js:103:16)
at Function.load (/Users/milewski/Code/backend/node_modules/@tsed/common/lib/di/services/InjectorService.js:350:24)
at InjectorService.<anonymous> (/Users/milewski/Code/backend/node_modules/@tsed/src/common/di/services/InjectorService.ts:209:32)
at Generator.next (<anonymous>)
at /Users/milewski/Code/backend/node_modules/tslib/tslib.js:107:75
at new Promise (<anonymous>)
(node:2952) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
(node:2952) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    [nodemon] clean exit - waiting for changes before restart

Question with InjectorToken

Hey guys, I have a question regarding the creation of new (business-)objects and the usage of them in within a service.
I have created a new Type "MonthView". Therefore I have an existing colleciton in my mongoDB which is called "monthviews". Now I want to do a simple .find operation in my service. I have created the model like that:
`import { InjectorService, JsonProperty } from 'ts-express-decorators';
import { prop, Typegoose, InstanceType, ModelType } from 'typegoose';
import { MonthViewRepoToken } from '../token-constants';

export class MonthView extends Typegoose {

@prop()
@JsonProperty()
year: string;

@prop()
@JsonProperty()
month: string;

@prop()
@JsonProperty()
day: string;

@prop()
@JsonProperty()
amount: string;

}

export type MonthViewInstance = InstanceType;
export type MonthViewRepo = ModelType;
InjectorService.factory(MonthViewRepoToken, new MonthView().getModelForClass(MonthView));
`

I am a little confused about the last line of code because this crashes my whole application. The login doesn't work any more, the same on signup route. When I comment the line out, then it starts to work again. It seems that the Collection "user" gets overwritten in some strange way. Can you maybe help me to figure that out?

Thanks!

build script --> no mounted routes

Hi there,
first of all I wanted to say thank you, your project is a really good starter for API-based projects. I have a question respectively wanted to report an possible error.
When I want to build my project for the production, I have to problem, that there are no mounted routes. When I'm runniung the start-script, everthing is fine and works, but not after the build and start:prod script. As I said there are no routes listed in the overview at the start o the server. My output is something like this:
`[2018-01-23T08:27:07.783] [INFO ] [TSED] - Build services
body-parser deprecated bodyParser: use individual json/urlencoded middlewares dist\server.js:38:22
body-parser deprecated undefined extended: provide extended option node_modules\body-parser\index.js:105:29
[2018-01-23T08:27:07.807] [INFO ] [TSED] - Build controllers

[2018-01-23T08:27:07.810] [INFO ] [TSED] - Routes mounted :

[2018-01-23T08:27:07.812] [INFO ] [TSED] -
┌────────┬──────────┬──────────────┐
│ Method │ Endpoint │ Class method │
└────────┴──────────┴──────────────┘

[2018-01-23T08:27:07.856] [INFO ] [TSED] - HTTP Server listen on http://0.0.0.0:3000
Server started...

[2018-01-23T08:27:07.858] [INFO ] [TSED] - Started in 194 ms

[2018-01-23T08:27:07.859] [INFO ] [TSED] - Server started...
`
Can you please advice me what to do?

Another point is that I had to change the start:prod script. It should be:
"start:prod": "node dist/app.js",
insted of
"start:prod": "node dist/main.js",

Thank you!

QST - Logged -In User

Hi @scopsy ,
is it possible to get the actual loggedIn user by the token within a service/controller? How can I do this?

Thanks and best regards!

Error when I'm installing npm packages

I cloned a repo, deleted .git directory and ran npm i but received an error:

...
In file included from ../../nan/nan.h:192:0,
                 from ../src/binding.cpp:1:
../../nan/nan_maybe_43_inl.h: In function ‘Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’:
../../nan/nan_maybe_43_inl.h:112:15: error: ‘class v8::Object’ has no member named ‘ForceSet’
   return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
               ^~~~~~~~
In file included from ../src/binding.cpp:1:0:
../../nan/nan.h: In function ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’:
...
binding.target.mk:115: recipe for target 'Release/obj.target/binding/src/binding.o' failed
make: *** [Release/obj.target/binding/src/binding.o] Error 1
make: Leaving directory '/home/elza/apps/cms/node_modules/node-sass/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/elza/apps/cms/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.9.0-8-amd64
gyp ERR! command "/usr/bin/node" "/home/elza/apps/cms/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/elza/apps/cms/node_modules/node-sass
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1

Please can you help me? Is it the repo up to date?

Geeting User not found all the time on login /v1/auth/login.

I am getting all the time user not found:

{
    "message": "User not found.",
    "code": 2001,
    "status": 404
}

When sending JSON with:

{
"email":"[email protected]",
"password":"password"
}

In local strategy:

const user = await this.userRepository.findOne({ email }, this.USER_TOKEN_FIELDS + ' password');
if (!user) throw new ApiError(API_ERRORS.USER_NOT_FOUND);

Of course this is not correct since that user exists in database.

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.