Git Product home page Git Product logo

typescript-express-starter's Introduction

agumon

Hi There! I'm a DevelopMon.

My main skills are NodeJs, JavaScript, TypeScript.

I'm a persistent person, who study hard day and night for be a good developer.πŸ₯°

πŸ’» Tech Stack

Β Β  Β Β 

πŸ“ˆ GitHub Stats

Agumon's top languages Agumon's github stats

πŸ† GitHub Trophy

typescript-express-starter's People

Contributors

ajvarparadise avatar alanmynah avatar amriksd avatar benjaminudoh10 avatar bityoungjae avatar davidjmstewart avatar dustinnewbold avatar edguy3 avatar engjellavdiu avatar florianmifsud avatar hichemfantar avatar ignatg avatar jagthefriend avatar joaopms avatar jonathanfelicity avatar jongio avatar joshuaoloduca avatar kubarozkwitalski avatar ljlm0402 avatar malavancs avatar markuslaubscher avatar n2ptune avatar noelzappy avatar pablosproject avatar seanpmaxwell avatar sonbyungjun avatar swtpumpkin avatar tamzidkarim avatar whatifwedigdeeper avatar yeondam88 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

typescript-express-starter's Issues

NODE_ENV

μ•ˆλ…•ν•˜μ„Έμš”.

app μ‹œμž‘μ‹œ enum νƒ€μž…μ˜ node_env λ₯Ό 가지면 μΆ”ν›„ ν™œμš©ν•  점이 μžˆμ„κ²ƒ κ°™μŠ΅λ‹ˆλ‹€~

enum NodeEnv {
  development = 'development',
  production = 'production',
}

Unable to use postgresql with this

Tried to set sequelize during the setup. Later, modified the configs and environments to use postgres but that doesn't allow me to use my postgresql server :( Am I doing it incorrectly?

Thank You

Thank you bro, It' help me a lot.
:)

Unable to start the server because Sequelize V6 is not yet supported by sequelize-typescript

This starter repository is not working anymore because of a recent major release of Sequelize V6. We are getting the following error:

TSError: β¨― Unable to compile TypeScript:
src/models/index.model.ts(25,22): error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type 'typeof User' is not assignable to type 'string | ModelCtor<Model<any, any>>'.
      Type 'typeof User' is not assignable to type 'ModelCtor<Model<any, any>>'.
        Type 'typeof User' is not assignable to type 'typeof Model'.
          Construct signature return types 'User' and 'Model<T, T2>' are incompatible.
            The types of '_attributes' are incompatible between these types.
              Type 'User' is not assignable to type 'T'.
                'T' could be instantiated with an arbitrary type which could be unrelated to 'User'.

    at createTSError (D:\___\code\api\node_modules\ts-node\src\index.ts:434:12)
    at reportTSError (D:\___\code\api\node_modules\ts-node\src\index.ts:438:19)
    at getOutput (D:\___\code\api\node_modules\ts-node\src\index.ts:578:36)
    at Object.compile (D:\___\code\api\node_modules\ts-node\src\index.ts:775:32)
    at Module.m._compile (D:\___\code\api\node_modules\ts-node\src\index.ts:858:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Object.require.extensions.<computed> [as .ts] (D:\___\code\api\node_modules\ts-node\src\index.ts:861:12)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
[nodemon] app crashed - waiting for file changes before starting...

sequelize-typescript is not yet upgraded to support Sequelize V6.
I think this one is the WIP: sequelize/sequelize-typescript#804

Create a new template knex

Motivation

Create a new template knex

kenx : https://knexjs.org/

Proposed Solution

Creating a new template using knex, SQL Query Builder

Alternatives

To provide a variety of templates

Additional Context

No swagger.yaml

Hey guys I just created a project via npx and I was trying to get in to the swagger in the scratch project and it not working. There is no even a swagger.yaml file.

How best to handle errors that come from database constraints?

Using the starter, if you have a service function do something that violates a database constraint (for example on uniqueness or table relationships), the error is uncaught and the API returns a 500. What is a good strategy for catching these errors and returning a 4xx and a better error message?

Modify Request type to include typed body

Summary(μš”μ•½)

Even though there exists a validationMiddleware that calls plainToClass() and transforms the body object into a class instance, this class instance is not preserved and will need to be transformed again in the route handler.

Additional Details(좔가적인 μ„ΈλΆ€ 사항)

What currently exists in the project in the controller is a simple cast const userData: CreateUserDto = req.body;, but that's lying to the compiler because userData is not actually an instance of CreateUserDto, this can be noticed if the Dto has methods or custom getters or setters. Is this a real concern? Or should we ignore this?
One replacement could be const userData = plainToClass(CreateUserDto, req.body);, but I was thinking that maybe we can make use of the validationMiddleware as it calls plainToClass already.

What do you think?

할일

.npmignore 둜 κΉƒν—ˆλΈŒ 폴더 μ •μ˜
이미지 파일 별도 레포 운영
typescript 폴더 제거 및 톡합

Is the template following the clean architecute from R.C. Martin?

Summary(μš”μ•½)

Is the template following the clean architecture from R.C. Martin?

Additional Details(좔가적인 μ„ΈλΆ€ 사항)

the template project has a template like
/model ( or entities)
/service
/controller
/routes
pattern: https://github.com/ljlm0402/typescript-express-starter

But I have problems matching it to this architecture which many say is the de facto standard for a good software architecture

Like where do I find the entities, use cases, controllers etc.
For me only the controller layer is easy to find. In the template example project its also in the folder controllers.
In the example project the controllers use services and the services access the database.
If I try to map it to the pictures, use cases are the services and the entities are the models. But the models in the github project contain database specific code (for example typeorm notations).

grafik

Cannot find module './'

Summary(μš”μ•½)

Getting error at npm start command

Additional Details(좔가적인 μ„ΈλΆ€ 사항)

  1. Project setup using command npx typescript-express-starter "project name"

  2. npm run start

Following error generated

`npx: installed 61 in 14.582s
Info: === tsc-alias starting ===
Info: 27 files were affected!
internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module './'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (D:\Paxcom\kinator-connector\dist\server.js:6:40)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: npm run build && cross-env NODE_ENV=production node dist/server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.`

Fix authMiddleware

Motivation(μƒˆλ‘œμš΄ κΈ°λŠ₯ μ„€λͺ…)

Verification of cookie or header authorization

Proposed Solution(κΈ°λŠ₯을 톡해 μ–»κ³ μž ν•˜λŠ” μ†”λ£¨μ…˜)

Alternatives(μ œμ•ˆ 된 μ†”λ£¨μ…˜μ΄ 더 λ‚˜μ€ 이유)

Additional Context(μΆ”κ°€ 사항)

Mongoose Template Build Error

Describe the Bug

mongoose template tsc build error

Version to Reproduce

node : v14.8.0(LTS)
npm : v6.14.9
mongoose : ^5.11.8
@types/mongoose : ^5.10.3

Steps to Reproduce & Version

  1. mongoose template created
  2. run script npm run start or 'num run build'

If applicable, add a link to a test case (as a zip file or link to a repository we can clone).

Expected Behavior

A clear and concise description of what you expected to happen.

Actual Behavior

image

A clear and concise description of what actually happened.

If applicable, add screenshots to help explain your problem.

Additional Context

Add any other context about the problem here.

Default template Unit Tests fail

When running the unit tests in the default version, the auth.test.ts fails:

` src/tests/auth.test.ts:25:36 - error TS2339: Property 'path' does not exist on type 'AuthRoute'.

25                 .post(`${authRoute.path}/signup`)
                                      ~~~~
src/tests/auth.test.ts:41:36 - error TS2339: Property 'path' does not exist on type 'AuthRoute'.

41                 .post(`${authRoute.path}/login`)
                                      ~~~~
src/tests/auth.test.ts:53:36 - error TS2339: Property 'path' does not exist on type 'AuthRoute'.

53                 .post(`${authRoute.path}/logout`)`

Even if this compilation error is fixed, the tests still fail:

FAIL src/tests/auth.test.ts (7.321 s)
● Testing Auth β€Ί [POST] /login β€Ί response should have the Set-Cookie header with the Authorization token

expected "Set-Cookie" header field

  at Test._assertHeader (node_modules/supertest/lib/test.js:237:45)
  at Test._assertFunction (node_modules/supertest/lib/test.js:283:11)
  at Test.assert (node_modules/supertest/lib/test.js:173:18)
  at Server.localAssert (node_modules/supertest/lib/test.js:131:12)

● Testing Auth β€Ί [POST] /logout β€Ί logout Set-Cookie Authorization=; Max-age=0

expected "Set-Cookie" header field

  at Test._assertHeader (node_modules/supertest/lib/test.js:237:45)
  at Test._assertFunction (node_modules/supertest/lib/test.js:283:11)
  at Test.assert (node_modules/supertest/lib/test.js:173:18)
  at Server.localAssert (node_modules/supertest/lib/test.js:131:12)

In the sequelize template I get the following:

FAIL src/tests/auth.test.ts
● Test suite failed to run

src/tests/users.test.ts:15:13 - error TS2740: Type 'typeof User' is missing the following properties from type 'User[]': pop, push, concat, join, and 25 more.

15       const findUser: User[] = userModel;
               ~~~~~~~~
src/tests/users.test.ts:28:40 - error TS2339: Property 'find' does not exist on type 'typeof User'.

28       const findUser: User = userModel.find(user => user.id === userId);
                                          ~~~~
src/tests/users.test.ts:28:45 - error TS7006: Parameter 'user' implicitly has an 'any' type.

28       const findUser: User = userModel.find(user => user.id === userId);
                                               ~~~~
src/tests/users.test.ts:74:44 - error TS2339: Property 'filter' does not exist on type 'typeof User'.

74       const deleteUser: User[] = userModel.filter(user => user.id !== userId);
                                              ~~~~~~
src/tests/users.test.ts:74:51 - error TS7006: Parameter 'user' implicitly has an 'any' type.

74       const deleteUser: User[] = userModel.filter(user => user.id !== userId);
                                                     ~~~~

FAIL src/tests/users.test.ts
● Test suite failed to run

src/models/index.model.ts:25:22 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type 'typeof User' is not assignable to type 'string | ModelCtor<Model<any, any>>'.
      Type 'typeof User' is not assignable to type 'ModelCtor<Model<any, any>>'.
        Type 'typeof User' is not assignable to type 'typeof Model'.
          Construct signature return types 'User' and 'Model<T, T2>' are incompatible.
            The types of '_attributes' are incompatible between these types.
              Type 'User' is not assignable to type 'T'.
                'T' could be instantiated with an arbitrary type which could be unrelated to 'User'.

25 sequelize.addModels([User]);
                        ~~~~

  node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.d.ts:16:5
    16     addModels(arg: Array<ModelCtor | string>): any;
           ~~~~~~~~~
    The last overload is declared here.

FAIL src/tests/index.test.ts
● Test suite failed to run

TypeError: Cannot read property 'getQueryInterface' of undefined

  at Function.get queryInterface [as queryInterface] (node_modules/sequelize/lib/model.js:55:27)
  at isFunctionMember (node_modules/sequelize-typescript/dist/model/model/model.js:99:25)
  at node_modules/sequelize-typescript/dist/model/model/model.js:96:5
      at Array.filter (<anonymous>)
  at Object.<anonymous> (node_modules/sequelize-typescript/dist/model/model/model.js:95:6)
  at Object.<anonymous> (node_modules/sequelize-typescript/dist/model/shared/model-service.js:3:17)

I've not tried the mongoose version, but I'm guessing that will have similiar issues. I'm guessing these are still work in progress.

Build fails when using TypeORM installation.

Describe the Bug(버그 μ„€λͺ…)

After creating the project npx typescript-express-starter [project name] and running npm i. Running npm start builds the project, but when node tries to run the built output, it spits out this error.

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/chris/Projects/NodeAPI/node_modules/swagger-jsdoc/index.js
require() of ES modules is not supported.
require() of /Users/chris/Projects/NodeAPI/node_modules/swagger-jsdoc/index.js from /Users/chris/Projects/NodeAPI/build/app.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/chris/Projects/NodeAPI/node_modules/swagger-jsdoc/package.json.

Version to Reproduce(ν˜„μž¬ μ‚¬μš©ν•œ 버전)

This was running on a Mac using Node 14.15.5

Steps to Reproduce(μž¬ν˜„ μˆœμ„œ)

Expected Behavior(μ˜ˆμƒ λ™μž‘)

I expect the project to build and run successfully even if it can't connect to a database or anything.

Actual Behavior(μ‹€μ œ λ™μž‘)

The error shown above.

Please acknowledge where you copied this project from

This exact line is from my readme in express-generator-typescript

"Node Js is great for the rapid development of web-projects, but is often neglected because of the lack of type safety. TypeScript solves this issue and (along with its linter file) can even make your code more robust than some other static languages like Java." Plus a huge chunk of other code is identical.

I know express-generator-typescript is an open source project but at least acknowledge your project as a fork/variation of mine you're going to copy me line-by-line.

Jest unit test fails

Describe the Bug

yarn test or "npm run test" fails connect method of mongoose cannot be mocked.
As a result all of the test cases fail.

Version to Reproduce

Steps to Reproduce

npm install -g typescript-express-starter
npx typescript-express-starter nodeExpressTsSample
npm run test

Expected Behavior

The test cases should pass.

Actual Behavior

Test cases fail with error:
TypeError: Cannot read property 'then' of undefined
mongoose_1.connect(database_1.dbConnection.url, database_1.dbConnection.options)
.then(() => {
^
logger_1.logger.info('🟒 The database is connected.');

If applicable, add screenshots to help explain your problem. -->

Additional Context

Capture screen

image

Possible issue with sequalize logout function - security issue?

Describe the Bug(버그 μ„€λͺ…)

On line 44 of the uth.service.ts file in the sequalize folder I have noticed that you search for a user only by their password. I am not sure what the user being returned is used for (as they are being logged out) but it seems to me that you could return an incorrect user if 2 users were to use the same password. Suggest changing this to search for user by a unique field or email and password combination?

Version to Reproduce(ν˜„μž¬ μ‚¬μš©ν•œ 버전)

Any environment.

Steps to Reproduce(μž¬ν˜„ μˆœμ„œ)

  1. Create a user with password "password"
  2. Create a second user with password "password"
  3. Login as the second user
  4. Log out
  5. You will be returned user from step 1 above when you were logged in as user from step 2!

Expected Behavior(μ˜ˆμƒ λ™μž‘)

Should return the user you are logged in as.

Actual Behavior(μ‹€μ œ λ™μž‘)

A different user (with the same password) is returned.

Additional Context(μΆ”κ°€ 사항)

This same technique seems to be used in TypeORM and mongoose as well. If it is an issue then it probably needs changing in all these.

Capture screen(캑쳐 ν™”λ©΄)

Feature Request : Make Things Optional

We need a project that just works right after created. That helps to make trying things extremely easy and so attracts more people. That project fits me almost perfectly, no Passport things, creates auth and DB stuff, and so on. But, not including Pug is a minus.
I believe, if we can make these things optional we can put that project as an industry standard that helps people to code Node with TS.

generated issue

βœ– Please leave this error as an issue
Error: Command failed: npm i -s bcrypt class-transformer class-validator cookie-parser cors cross-env dotenv envalid express helmet hpp jest jsonwebtoken morgan swagger-jsdoc swagger-ui-express ts-jest ts-node typescript mysql2 sequelize sequelize-typescript

at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {

killed: false,
code: 1,
signal: null,
cmd: 'npm i -s bcrypt class-transformer class-validator cookie-parser cors cross-env dotenv envalid express helmet hpp jest jsonwebtoken morgan swagger-jsdoc swagger-ui-express ts-jest ts-node typescript mysql2 sequelize sequelize-typescript',
stdout: "Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/asya/prjcts/adminkoSwaponline/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/asya/prjcts/adminkoSwaponline/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=6 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)\n",
stderr: ''
}

Create a new template graphql

Motivation(μƒˆλ‘œμš΄ κΈ°λŠ₯ μ„€λͺ…)

Create a new template graphql

graphql: https://graphql.org/

Proposed Solution(κΈ°λŠ₯을 톡해 μ–»κ³ μž ν•˜λŠ” μ†”λ£¨μ…˜)

Creating a new template using graphql, A query language for your API

Alternatives(μ œμ•ˆ 된 μ†”λ£¨μ…˜μ΄ 더 λ‚˜μ€ 이유)

To provide a variety of templates

Additional Context(μΆ”κ°€ 사항)

Fix validationMiddleware

Motivation(μƒˆλ‘œμš΄ κΈ°λŠ₯ μ„€λͺ…)

If the skipMissingProperties value of validation middleware is set to true, the corresponding function is not performed at all.

However, it is necessary to determine the req data based on dto, and verification of other req data is required.

Proposed Solution(κΈ°λŠ₯을 톡해 μ–»κ³ μž ν•˜λŠ” μ†”λ£¨μ…˜)

For example, it is composed of dto = email, password, but if the data of req.body is added as email, password, name, and name data is added, the corresponding verification must be done even if skipMissingProperties = true.

Alternatives(μ œμ•ˆ 된 μ†”λ£¨μ…˜μ΄ 더 λ‚˜μ€ 이유)

Additional Context(μΆ”κ°€ 사항)

getting error related to validationMiddleware

When I run server with default implementation, I get this:

TSError: β¨― Unable to compile TypeScript:
src/middlewares/validation.middleware.ts:9:33 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Request<ParamsDictionary, any, any, ParsedQs>'.
  No index signature with a parameter of type 'string' was found on type 'Request<ParamsDictionary, any, any, ParsedQs>'.

9     validate(plainToClass(type, req[value]), { skipMissingProperties })

How can I fix this?

ReferenceError: exports is not defined

default template
node v15.11.0

Info: === tsc-alias starting ===
Info: 11 files were affected!
file:///Users/user/Desktop/Code/butter/dist/server.js:2
Object.defineProperty(exports, "__esModule", { value: true });
^

ReferenceError: exports is not defined
at file:///Users/user/Desktop/Code/butter/dist/server.js:2:23
at ModuleJob.run (node:internal/modules/esm/module_job:154:23)
at async Loader.import (node:internal/modules/esm/loader:166:24)

tsconfig.json
{ "compileOnSave": false, "compilerOptions": { "target": "es2017", "lib": ["es2017", "esnext.asynciterable"], "typeRoots": ["node_modules/@types"], "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "forceConsistentCasingInFileNames": true, "moduleResolution": "node", "module": "commonjs", "pretty": true, "sourceMap": true, "declaration": true, "outDir": "./dist", "skipLibCheck": true, "allowJs": true, "noEmit": false, "esModuleInterop": true, "resolveJsonModule": true, "importHelpers": true, "baseUrl": "src", "paths": { "@app": ["app"], "@controllers/*": ["controllers/*"], "@dtos/*": ["dtos/*"], "@exceptions/*": ["exceptions/*"], "@interfaces/*": ["interfaces/*"], "@middlewares/*": ["middlewares/*"], "@models/*": ["models/*"], "@routes/*": ["routes/*"], "@services/*": ["services/*"], "@utils/*": ["utils/*"] } }, "include": ["src/**/*.ts", "src/**/*.json", ".env"], "exclude": ["node_modules"] }

Generating Migrations and Models with Sequelize

Summary

Is there any specific CLI command to generate all the interfaces for Sequelize Models etc using just a single command in your project? Turns out sequelize migrate creates plain old js files.

Unit Tests Errors describe logout (cookie)

Describe the Bug

Cookie data does not exist, causing middleware errors

Steps to Reproduce

auth.test.ts files describe logout

Expected Behavior

Actual Behavior

Additional Context

Capture screen

image

when i use npx typescript-express-starter "project name"

The files are creating and after sometime it says as below


Γ— Please leave this error as an issue
Error: Command failed: npm i -s  bcrypt class-transformer class-validator compression config cookie-parser cors cross-env dotenv envalid express helmet hpp jest jsonwebtoken morgan [email protected] swagger-ui-express ts-jest ts-node typescript winston winston-daily-rotate-file

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'npm i -s  bcrypt class-transformer class-validator compression config cookie-parser cors cross-env dotenv envalid express helmet hpp jest jsonwebtoken morgan [email protected] swagger-ui-express ts-jest ts-node typescript winston winston-daily-rotate-file',
  stdout: '',
  stderr: ''
}

New Feature pm2

Motivation

Adding a new function pm2

pm2 : https://pm2.keymetrics.io/

Proposed Solution

Adding a new function pm2, ADVANCED, PRODUCTION PROCESS MANAGER FOR NODE.JS

Alternatives

Cluster mode, Load balancing, keep applications alive forever

Additional Context

Helmet is not a function

When trying to run the application, an exception is being thrown:

this.app.use(helmet()); ^ TypeError: helmet_1.default is not a function at App.initializeMiddlewares (C:\Source\TnT\TnT2\src\app.ts:39:26) at new App (C:\Source\TnT\TnT2\src\app.ts:20:10) at Object.<anonymous> (C:\Source\TnT\TnT2\src\server.ts:10:13) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Module.m._compile (C:\Source\TnT\TnT2\node_modules\ts-node\src\index.ts:1043:23) at Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Object.require.extensions.<computed> [as .ts] (C:\Source\TnT\TnT2\node_modules\ts-node\src\index.ts:1046:12) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)

The fix seems to be changing the import statement in app.ts from:

import helmet from 'helmet';

to

import * as helmet from 'helmet'

I'm happy to submit to resolve this myself, but I'm not sure if this is by design or not.

Starting the app throws an error (Ubuntu)

Describe the Bug(버그 μ„€λͺ…)

Anytime you tired to npm start (or run the built server), it would fail with:

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module './'
Require stack:

Version to Reproduce(ν˜„μž¬ μ‚¬μš©ν•œ 버전)

Ubuntu 20.04, Node v12.22.1, npm v6.14.12

Steps to Reproduce(μž¬ν˜„ μˆœμ„œ)

  1. Start a new project with Prisma
  2. Run npm install
  3. Run npm start

Expected Behavior(μ˜ˆμƒ λ™μž‘)

Its expected to start the server up on port 3000 but fails.

Actual Behavior(μ‹€μ œ λ™μž‘)

Fails and quits server.

Additional Context(μΆ”κ°€ 사항)

I fixed this by changing line 4 of server.ts from:

import App from '@app';

to:

import App from './app';

Capture screen(캑쳐 ν™”λ©΄)

image

Todo

  1. Add REST Client
  2. Create TypeORM Template
  3. Fix TSLint -> ESLint

Sequelize template seems to be broken

Describe the Bug(버그 μ„€λͺ…)

When using the sequelize template and running the project with docker compose up -d I get an error when the node application tries to interact with the database.

Not sure if the templates are suppose to be working examples.

Version to Reproduce(ν˜„μž¬ μ‚¬μš©ν•œ 버전)

Used with Docker

Steps to Reproduce(μž¬ν˜„ μˆœμ„œ)

  1. npx typescript-express-starter
  2. select sequelize template
  3. GET request --> http://localhost:3000/users

Expected Behavior(μ˜ˆμƒ λ™μž‘)

Actual Behavior(μ‹€μ œ λ™μž‘)

error: [GET] /users >> StatusCode:: 500, Message:: connect ECONNREFUSED 127.0.0.1:3306

Additional Context(μΆ”κ°€ 사항)

ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3306

at ConnectionManager.connect (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116:17)

at processTicksAndRejections (internal/process/task_queues.js:93:5)

at ConnectionManager._connect (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)

at /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32

at ConnectionManager.getConnection (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)

at /app/node_modules/sequelize/lib/sequelize.js:613:26

at MySQLQueryInterface.select (/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:953:12)

at Function.findAll (/app/node_modules/sequelize/lib/model.js:1753:21)

at UserService.findAllUser (/app/src/services/users.service.ts:12:29)

at UsersController.getUsers (/app/src/controllers/users.controller.ts:11:40) {

parent: Error: connect ECONNREFUSED 127.0.0.1:3306

at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {

errno: -111,

code: 'ECONNREFUSED',

syscall: 'connect',

address: '127.0.0.1',

port: 3306,

fatal: true

},

original: Error: connect ECONNREFUSED 127.0.0.1:3306

at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {

errno: -111,

code: 'ECONNREFUSED',

syscall: 'connect',

address: '127.0.0.1',

port: 3306,

fatal: true

}

}

2021-06-09 19:19:44 error: connect ECONNREFUSED 127.0.0.1:3306

New Feature Makefile

Motivation (μƒˆλ‘œμš΄ κΈ°λŠ₯ μ„€λͺ…)

New Feature Makefile

docker build : https://docs.docker.com/engine/reference/commandline/build/

Proposed Solution (κΈ°λŠ₯을 톡해 μ–»κ³ μž ν•˜λŠ” μ†”λ£¨μ…˜)

Build an image from a Dockerfile

Alternatives (μ œμ•ˆ 된 μ†”λ£¨μ…˜μ΄ 더 λ‚˜μ€ 이유)

Additional Context (μΆ”κ°€ 사항)

Cannot see the actual error messages .

Describe the Bug(버그 μ„€λͺ…)

The only error message received while running the project is :

[nodemon] app crashed - waiting for file changes before starting...

Version to Reproduce(ν˜„μž¬ μ‚¬μš©ν•œ 버전)

4.3.1

Steps to Reproduce(μž¬ν˜„ μˆœμ„œ)

  1. create default project using the cli
  2. Run : npm run dev , at this stage project runs fine.
  3. Create a typo in any .ts file for example: server.ts . Then save the file.
  4. [nodemon] app crashed - waiting for file changes before starting... , this error message is received.

This is a simple replication but not knowing what error occurred and where it occurred is really difficult to debug.

Expected Behavior(μ˜ˆμƒ λ™μž‘)

The error messages should show the stack trace not just single line saying app has crashed.

    at Object.<anonymous> (/home/user/Documents/projects/node/typescript-express-starter/src/server.ts:12:13)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

Actual Behavior(μ‹€μ œ λ™μž‘)

Only this error message is displayed:

[nodemon] app crashed - waiting for file changes before starting...

Additional Context(μΆ”κ°€ 사항)

node version:14.17.0
operating system: ubuntu 20.04

Capture screen(캑쳐 ν™”λ©΄)

screen recording:
https://imgur.com/a/jEHKwAH

https://ibb.co/RBWdb9Y

Feature Request: Sequelize-cli Integration

Hi guys! Great work on this project! Thanks for saving me a lot of headaches!

If there could be some sequelize-cli integration on this project(to generate migration and etc), or document on how to set it up, it'd be great! Thanks again for your work.

Why aren't the services static?

Is there any reason that classes like userService aren't static?

Wouldn't it be easier to call the method without having to initiate an object?

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.