Giter Site home page Giter Site logo

geekyants / express-typescript Goto Github PK

View Code? Open in Web Editor NEW
1.1K 20.0 307.0 1010 KB

Express + TypeScript + Boilerplate for Web / API App

Home Page: https://geekyants.github.io/express-typescript/

License: MIT License

TypeScript 58.28% CSS 8.77% JavaScript 3.04% Pug 29.45% Dockerfile 0.45%
express typescript boilerplate exception-handling node-cluster logging express-typescript-tutorial express-typescript express-typescript-boilerplate express-docker

express-typescript's People

Contributors

daskabe avatar faizahmedfarooqui avatar jonasclaes avatar jsingh0026 avatar rajat117 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

express-typescript's Issues

Getting lint error

Describe the bug
Getting the error while npm run dev
`[06:59:17] File change detected. Starting incremental compilation...

src/controllers/Auth/Login.ts:52:30 - error TS2339: Property 'returnTo' does not exist on type 'Session & Partial'.

52 res.redirect(req.session.returnTo || '/account');
~~~~~~~~

src/models/User.ts:72:30 - error TS2339: Property 'fullname' does not exist on type 'Document<any, any, any>'.

72 const fulladdress = ${this.fullname.trim()} ${this.geolocation.trim()};
~~~~~~~~

src/models/User.ts:72:54 - error TS2339: Property 'geolocation' does not exist on type 'Document<any, any, any>'.

72 const fulladdress = ${this.fullname.trim()} ${this.geolocation.trim()};
~~~~~~~~~~~

src/models/User.ts:78:40 - error TS2339: Property 'password' does not exist on type 'Document<any, any, any>'.

78 bcrypt.compare(_requestPassword, this.password, (_err, _isMatch) => {
~~~~~~~~

src/models/User.ts:90:13 - error TS2339: Property 'email' does not exist on type 'Document<any, any, any>'.

90 if (! this.email) {
~~~~~

src/models/User.ts:94:51 - error TS2339: Property 'email' does not exist on type 'Document<any, any, any>'.

94 const md5 = crypto.createHash('md5').update(this.email).digest('hex');
~~~~~

src/providers/Express.ts:63:29 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type '(_error: any) => void' is not assignable to parameter of type '() => void'.

63 this.express.listen(port, (_error: any) => {
~~~~~~~~~~~~~~~~~~

node_modules/@types/express-serve-static-core/ts4.0/index.d.ts:1115:5
1115 listen(handle: any, listeningListener?: () => void): http.Server;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.

src/routes/Web.ts:40:27 - error TS2339: Property 'returnTo' does not exist on type 'Session & Partial'.

40 res.redirect(req.session.returnTo || '/');
~~~~~~~~

[06:59:19] Found 8 errors. Watching for file changes.

src/controllers/Auth/Login.ts:52:30 - error TS2339: Property 'returnTo' does not exist on type 'Session & Partial'.

52 res.redirect(req.session.returnTo || '/account');
~~~~~~~~

src/models/User.ts:72:30 - error TS2339: Property 'fullname' does not exist on type 'Document<any, any, any>'.

72 const fulladdress = ${this.fullname.trim()} ${this.geolocation.trim()};
~~~~~~~~

src/models/User.ts:72:54 - error TS2339: Property 'geolocation' does not exist on type 'Document<any, any, any>'.

72 const fulladdress = ${this.fullname.trim()} ${this.geolocation.trim()};
~~~~~~~~~~~

src/models/User.ts:78:40 - error TS2339: Property 'password' does not exist on type 'Document<any, any, any>'.

78 bcrypt.compare(_requestPassword, this.password, (_err, _isMatch) => {
~~~~~~~~

src/models/User.ts:90:13 - error TS2339: Property 'email' does not exist on type 'Document<any, any, any>'.

90 if (! this.email) {
~~~~~

src/models/User.ts:94:51 - error TS2339: Property 'email' does not exist on type 'Document<any, any, any>'.

94 const md5 = crypto.createHash('md5').update(this.email).digest('hex');
~~~~~

src/providers/Express.ts:63:29 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type '(_error: any) => void' is not assignable to parameter of type '() => void'.

63 this.express.listen(port, (_error: any) => {
~~~~~~~~~~~~~~~~~~

node_modules/@types/express-serve-static-core/ts4.0/index.d.ts:1115:5
1115 listen(handle: any, listeningListener?: () => void): http.Server;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.

src/routes/Web.ts:40:27 - error TS2339: Property 'returnTo' does not exist on type 'Session & Partial'.

40 res.redirect(req.session.returnTo || '/');
~~~~~~~~`

To Reproduce
Steps to reproduce the behavior:

  1. Go to tsconfig
  2. make a changes
    "compilerOptions": { "target": "es6", "module": "commonjs", "outDir": "dist/", "sourceMap": true, "skipLibCheck": true }, "files": [ "./node_modules/@types/mocha/index.d.ts", // "./node_modules/@types/node/index.d.ts", // "./node_modules/@types/mongoose/index.d.ts", // "./node_modules/@types/mongodb/index.d.ts", "./node_modules/@types/express/index.d.ts", "./node_modules/@types/dotenv/index.d.ts", "./node_modules/@types/express-session/index.d.ts" ],
    to avoid #6 issue

Expected behavior
Should start without these error

Getting error while running npm run dev command

I am getting an error while running the command npm run dev. also attach a screenshot below for your reference.

image

If I am using the nodemon command to run Project running properly.

Please help what step I need to follow to resolve this error.

Thanks in advance.

Error: `useCreateIndex` is an invalid option.

Describe the bug
The app fails to run or start a connection to a mongodb url because of a deprecated option being set.

To Reproduce
Steps to reproduce the behavior:

  1. run yarn dev or npm run dev

Expected behavior
The Application fails to start

Screenshots

Desktop (please complete the following information):

  • OS: iOS 12.5

Smartphone (please complete the following information):
N/A

Additional context
For versions of Mongoose >= 6, setting useCreateIndex is invalid, and this boilerplate uses >=6.4.6

Changes are not reflected in the docker container

When I make any changes in the /controller directory, they do not get reflected in the api request itself
example: changed under /controllers/Api/Home.ts

class Home {
  public static index(req, res, next): any {
    return res.json({
      message: "hi", // Locals.config().name,
    });
  }
}

but the API response is still the name of the app not "hi" unless I restart the docker container.

missing script

(removed the template, as this is a generic error, not a functional one).

Check Dockerfile:

# Run node server
CMD npm run start

check package.json:

 "scripts": {
    "build": "tsc --project './tsconfig.json'",
    "dev": "tsc --project './tsconfig.json' --watch & NODE_ENV=development nodemon dist",
    "test": "tsc --project './tsconfig.json' && ./node_modules/.bin/mocha dist/**/*.spec.js",
    "lint": "./node_modules/.bin/tslint -c tslint.json 'src/**/**.ts'"
  }

notice, there's no declared command with the name of start.

UnhandledPromiseRejectionWarning: MongoError: (Unauthorized) not authorized on admin to execute command

Describe the bug
The application throws a rejection which i believe has to do with the sessions package trying to make updates to mongodb on start. Full error log below


[WARN] UnhandledPromiseRejectionWarning: MongoError: (Unauthorized) not authorized on admin to execute command { insert: "system.indexes", documents: [[{ns admin.sessions} {key [{expires 1}]} {name expires_1} {expireAfterSeconds 0} {unique false}]], ordered: true }
    at Function.MongoError.create (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/error.js:31:11)
    at /Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/pool.js:497:72
    at authenticateStragglers (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/pool.js:443:16)
    at Connection.messageHandler (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/pool.js:477:5)
    at TLSSocket.<anonymous> (/Users/user/Documents/projects/express-typescript/node_modules/mongodb-core/lib/connection/connection.js:333:22)
    at TLSSocket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
    at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)

To Reproduce
Steps to reproduce the behavior:

  1. run yarn dev or npm run dev

Expected behavior
App Should start

Screenshots
N/A

Desktop (please complete the following information):

  • OS: iOS 12.5

Smartphone (please complete the following information):
N/A

Additional context
Cannot use this template with session

.env file not find queueMonitor and queueMonitorHttpPort

for App.ts is loadQueue function:
1.const isQueueMonitorEnabled: boolean = Locals.config().queueMonitor;
2.const queueMonitorPort: number = Locals.config().queueMonitorHttpPort;

But .env not find queueMonitor and queueMonitorHttpPort

fresh install starts with errors

Describe the bug
fresh install starts with errors

To Reproduce
Steps to reproduce the behavior:

git clone https://github.com/faizahmedfarooqui/nodets.git;
cd nodets;
npm install;
vim .env;
npm run dev;

Desktop (please complete the following information):

  • OS: MacOS X 10.15.1
  • Node: v12.14.0

Additional context

[20:35:47] Starting compilation in watch mode...

node_modules/@types/node/index.d.ts:64:11 - error TS2300: Duplicate identifier 'IteratorResult'.

64 interface IteratorResult<T> { }
             ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.

node_modules/@types/node/index.d.ts:83:15 - error TS2451: Cannot redeclare block-scoped variable 'custom'.

83         const custom: symbol;
                 ~~~~~~

  node_modules/@types/node/ts3.2/util.d.ts:6:15
    6         const custom: unique symbol;
                    ~~~~~~
    'custom' was also declared here.
  node_modules/@types/node/ts3.2/util.d.ts:9:15
    9         const custom: unique symbol;
                    ~~~~~~
    and here.

node_modules/@types/node/index.d.ts:86:15 - error TS2451: Cannot redeclare block-scoped variable 'custom'.

86         const custom: symbol;
                 ~~~~~~

  node_modules/@types/node/ts3.2/util.d.ts:6:15
    6         const custom: unique symbol;
                    ~~~~~~
    'custom' was also declared here.
  node_modules/@types/node/ts3.2/util.d.ts:9:15
    9         const custom: unique symbol;
                    ~~~~~~
    and here.

node_modules/@types/node/ts3.2/util.d.ts:6:15 - error TS2451: Cannot redeclare block-scoped variable 'custom'.

6         const custom: unique symbol;
                ~~~~~~

  node_modules/@types/node/index.d.ts:83:15
    83         const custom: symbol;
                     ~~~~~~
    'custom' was also declared here.
  node_modules/@types/node/index.d.ts:86:15
    86         const custom: symbol;
                     ~~~~~~
    and here.

node_modules/@types/node/ts3.2/util.d.ts:9:15 - error TS2451: Cannot redeclare block-scoped variable 'custom'.

9         const custom: unique symbol;
                ~~~~~~

  node_modules/@types/node/index.d.ts:83:15
    83         const custom: symbol;
                     ~~~~~~
    'custom' was also declared here.
  node_modules/@types/node/index.d.ts:86:15
    86         const custom: symbol;
                     ~~~~~~
    and here.

node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.

41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
        ~~~~~~~~~~~~~~

  node_modules/@types/node/index.d.ts:64:11
    64 interface IteratorResult<T> { }
                 ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.

[20:35:51] Found 6 errors. Watching for file changes.

Dependency Conflict typescript@"5.0.3" & awesome-typescript-loader@"^5.2.0"

Describe the bug
When running npm install locally, I get a dependency conflict when resolving the dependency tree

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/typescript
npm ERR! dev typescript@"5.0.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@"^2.7 || ^3" from [email protected]
npm ERR! node_modules/awesome-typescript-loader
npm ERR! dev awesome-typescript-loader@"^5.2.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/lennart/.npm/_logs/2023-06-19T11_22_57_010Z-eresolve-report.txt

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repository
  2. Run npm install
  3. See error

Expected behavior
Npm install is able to run without error

Desktop (please complete the following information):

  • OS: [e.g. iOS] macOS
  • Browser [e.g. chrome, safari] N/A
  • Version [e.g. 22] 12.6.6

**/node_modules/@types/mongoose/index.d.ts' not found

Describe the bug
Getting `error TS6053: File '/Users/**/node_modules/@types/mongoose/index.d.ts' not found. while starting npm run dev

[06:19:09] Found 1 error. Watching for file changes.`

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repo and do npm i
  2. Do npm run dev

Expected behavior
Should start without error

App don't start on linux Manjaro i3-gaps (Arch)

Describe the bug
I cant start the app on Manjaro I3.

I clone the repo, then install node packages with yarn and finally i

sudo yarn dev 
sudo npm run dev

and i get this error:

[15:57:43] Starting compilation in watch mode...

src/providers/Express.ts:63:29 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '(_error: any) => void' is not assignable to parameter of type '() => void'.

63  	this.express.listen(port, (_error: any) => {
    	                          ~~~~~~~~~~~~~~~~~~

  node_modules/@types/express-serve-static-core/index.d.ts:1036:5
    1036     listen(handle: any, listeningListener?: () => void): http.Server;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.

[15:57:47] Found 1 error. Watching for file changes.

Project doesn't build

Describe the bug
This repo does not build. complains about ./tsconfig.json not found. but its there.

PS C:\Users\a\Desktop\deleteme2\express-typescript> npm run build

> [email protected] build
> tsc --project './tsconfig.json'

error TS5058: The specified path does not exist: ''./tsconfig.json''.

if i do nox tsc in the project i get 311 errors something to do with mongoose mostly.

....
node_modules/mongoose/types/expressions.d.ts:2880:20 - error TS1110: Type expected.

2880   type UTCOffset = `${hh}` | `${hh}${mm}` | `${hh}:${mm}`;
                        ~~~

node_modules/mongoose/types/pipelinestage.d.ts:220:82 - error TS1110: Type expected.

220       $replaceWith: ObjectExpressionOperator | { [field: string]: Expression } | `$${string}`;
                                                                                     ~~~~

node_modules/mongoose/types/pipelinestage.d.ts:297:1 - error TS1128: Declaration or statement expected.

297 }
    ~


Found 311 errors.

To Reproduce
Steps to reproduce the behavior:

  1. clone repo
  2. npm i
  3. npm r build

Expected behavior
it should build and produce dist folder

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Win11
  • npm: '8.1.2',
  • node: '16.13.2',
  • v8: '9.4.146.24-node.14',
  • tsc: version 5.0.2

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.