profile
viewpoint
Sean Maxwell seanpmaxwell Web-developer, creator of OvernightJS, and lover of all things JavaScript/TypeScript.

seanpmaxwell/overnight 571

TypeScript decorators for the ExpressJS Server.

seanpmaxwell/express-generator-typescript 285

Create a new express app similar to express-generator but with TypeScript

seanpmaxwell/Trool 75

A rule engine for NodeJS written in TypeScript

seanpmaxwell/TypeScriptFullStackShell 61

Setting up a web application for full-stack TypeScript development

seanpmaxwell/ExpressTypeScript 43

Develop and ExpressJS webserver using TypeScript

seanpmaxwell/simple-color-print 4

Print to the console in different colors and fully print objects

seanpmaxwell/typescript-express-starter 3

🚀 TypeScript Express Starter

seanpmaxwell/SimplePaint 2

Rewrite of an old java project I did back in school

startedbevacqua/react-dragula

started time in 11 days

issue commentseanpmaxwell/Trool

Export rules from table

You mean actually export the Datatable objects that are generated from reading the CSV file?

jKh98

comment created time in 16 days

issue commentseanpmaxwell/express-generator-typescript

log transpile (tsc) error

hmmm I'll think about it, seems a little scattered. I'll see if there's a way to throw tsc errors in npm

surlacolline

comment created time in 20 days

issue commentseanpmaxwell/overnight

Why not async-wrap everything by default?

Well the reason I don't do that is because ExpressJS doesn't do that. I'm not trying to create an abstraction over ExpressJS, just provide decorators.

jondot

comment created time in 23 days

startednodejs/node

started time in 24 days

startedJeff-Lewis/cls-hooked

started time in 24 days

issue closedseanpmaxwell/overnight

Class Middleware apply to all routes in all controllers with the same route prefix rather than all routes in that particular class

First of all, awesome works! Great module. Thank you.

I found this little issue in relating to middleware. Not sure wether it is by design or not. Could you help check.


Versions: ^1.6.9

Code Example:

1.Controller A - with route prefix /api/v1 attach to middlewareA



@Controller('api/v1/')
@ClassMiddleware([middleWareA])
export class ClassA {
    @Post('routeA1')
    private async a1(request: Request, response: Response) {
        return response.status(OK).json({})
    }

    @Post('routeA2')
    private async a2(request: Request, response: Response) {
        return response.status(OK).json({})
    }
}
  1. Controller B using the same prefix /api/v1 but has not assigned any middleware.
@Controller('api/v1/')
export class ClassB {
    @Post('routeB1')
    private async b1(request: Request, response: Response) {
        return response.status(OK).json({})
    }
}

Expected result:

middlewareA get invoke only in route in controller A

  • /api/v1/routeA1
  • /api/v1/routeA2

controller B /api/v1/routeB1 should get invoke directly without middlewareA

Actual result:

All route with prefix /api/v1/ got invoke with middlewareA

closed time in a month

birdbyrd

startedseanpmaxwell/typescript-express-starter

started time in 2 months

issue commentseanpmaxwell/express-generator-typescript

A little help with sending only json response

app.use('/api', BaseRouter) prepends 'api' to all the routes. Try calling '/api/mything/mythingroute'

cunundrummer

comment created time in 2 months

startedJakeHartnell/react-images-upload

started time in 2 months

push eventseanpmaxwell/express-generator-typescript

seanpmaxwell

commit sha 6a7a14953186d44a3362134114a9732fd7356656

updated readme and merged pull request 31

view details

push time in 2 months

PR closed seanpmaxwell/express-generator-typescript

feat: add nodemon config with --inspect flag

Solve #25 Add nodemon config with --inspect flag Example: node --inspect -r ts-node/register -r tsconfig-paths/register ./src --env=development

+16 -4

0 comment

6 changed files

Marcus-Rise

pr closed time in 2 months

issue closedseanpmaxwell/express-generator-typescript

Add support for nodemon debugging

Solid boilerplate, thank you But i wasn't able to implement nodemon debugging (when debugger reconnects when you change code). I've spent several hours to follow this article, but wasn't able to make module-aliasing work.

closed time in 2 months

DTX-92

issue commentseanpmaxwell/express-generator-typescript

Add support for nodemon debugging

Sorry buddy I think this is a bit too trivial and steers a bit from a default setup. I don't want --inspect configured by default. People can modify their nodemonConfig if they want debugging enable. I tell you this though, I'll update the readme and tell them where to add --inspect if they want debugging enabled.

DTX-92

comment created time in 2 months

push eventseanpmaxwell/express-generator-typescript

Ilya Konstantinov

commit sha cfbe8f6028770318b9f9e3e62a8dc54b6ea32e7b

refactor(withAuth/src/Server.ts): use already defined constant

view details

Sean Maxwell

commit sha 4d2778a4bf6494265134c67f5cb136440f9fd767

Merge pull request #31 from Marcus-Rise/refactor/server-config Use already defined constant

view details

push time in 2 months

push eventseanpmaxwell/express-generator-typescript

seanpmaxwell

commit sha bf5b03ae8db5a146000fa90289a7680b119af4e1

committing pull request and updating version

view details

push time in 2 months

push eventseanpmaxwell/express-generator-typescript

Nuttapat Koonarangsri

commit sha 728898e0c079289eb70668c9bccef3f661182bea

throw error if tsc fails to build

view details

Sean Maxwell

commit sha cdf68c36595ef9db08d4b6661b5dd29bf12741b3

Merge pull request #30 from hackinteach/master throw error if tsc fails to build

view details

push time in 2 months

PR merged seanpmaxwell/express-generator-typescript

throw error if tsc fails to build

this prevents docker from being successfully built while project file is failed to build and hence docker image is broken.

+6 -1

0 comment

1 changed file

hackinteach

pr closed time in 2 months

issue commentseanpmaxwell/express-generator-typescript

Project setup error

Hmm I just ran it on windows 10 and it worked fine for me hmmmm try running: npm i -D ts-node tslint typescript nodemon find jasmine supertest ' + '@types/node @types/express @types/jasmine @types/find @types/morgan ' + '@types/cookie-parser @types/supertest fs-extra tsconfig-paths @types/jsonfile ' + 'jsonfile @types/command-line-args @types/helmet

directly cause it looks like that command is failing in the script

temetvince

comment created time in 2 months

push eventseanpmaxwell/express-generator-typescript

seanpmaxwell

commit sha a213a17b31005f399fcdca1c0cf94e58ea295a51

moved nodemon to package.json

view details

push time in 2 months

push eventseanpmaxwell/express-generator-typescript

seanpmaxwell

commit sha c98812f4bb1e43ddc1924da6a0234bdcaa4ca967

removed WithAuth

view details

push time in 2 months

push eventseanpmaxwell/express-generator-typescript

seanpmaxwell

commit sha 2451e6a81e593d36b0c0ffb00fde871dfa2e185a

moved nodemon to package.json

view details

push time in 2 months

issue closedseanpmaxwell/overnight

'Server' no longer exported

After upgrading from v1.7.3 of @overnightjs/core.

My TypeScript import statement:

import { Server } from '@overnightjs/core';

gives the error:

Module '"../node_modules/@overnightjs/core/lib"' has no exported member 'Server'.ts(2305)

Tracing this back to @overnightjs/core/lib/index.d.ts the error is:

Could not find a declaration file for module './Server'. '../node_modules/@overnightjs/core/lib/Server.js' implicitly has an 'any' type.ts(7016)

Downgrading to v1.7.2 fixes the issue.

@overnightjs/core: 1.7.3 typescript: ~3.8.3

closed time in 3 months

gmaughan

issue commentseanpmaxwell/overnight

'Server' no longer exported

let me know if 1.7.4 fixes the issue for you

gmaughan

comment created time in 3 months

issue closedseanpmaxwell/overnight

Unable to access "this" inside controllers

I have a simple controller with the following code

import expressAsyncHandler from 'express-async-handler'
import { Controller, ClassErrorMiddleware, Post, Wrapper } from '@overnightjs/core'
import { Logger } from '@overnightjs/logger'
import { OK } from 'http-status-codes'
import { myAsyncAction } from './actions'
import { LogErrorAndStop } from '../middleware/error-handlers'

@Controller("api/auth")
@ClassErrorMiddleware(LogErrorAndStop)
export class AuthController {
    private thingINeedFromClass: string

   constructor() {
       this.thingINeedFromClass = "TEST"
   }

    @Post("sign-up")
    @Wrapper(expressAsyncHandler)
    private async signUp(req: Request, res: Response): Promise<void> {
        Logger.Info("Sign up called")
        Logger.Info(req.body, true)

        console.log(this) // <----

        await myAsyncAction(this.thingINeedFromClass)

       res.status(OK)
    }
}

When I log this it's undefined. If I try and call the same function in this class without the Class decorator, this is accessible as expected.

overnight version 1.7.2

Thanks !

closed time in 3 months

ryanpierre

issue commentseanpmaxwell/overnight

Unable to access "this" inside controllers

@joeykilpatrick v1.7.4 has this change

ryanpierre

comment created time in 3 months

push eventseanpmaxwell/overnight

seanpmaxwell

commit sha cdf40374a647daa89a6ed7545685cdf924af018c

fixed an error in tsconfig

view details

push time in 3 months

issue commentseanpmaxwell/express-generator-typescript

npm start not working

Oh yeah. If you look at tsconfig it points to src/. You need to modify this file if you want typescript files in other places.

iampeters

comment created time in 3 months

issue commentseanpmaxwell/express-generator-typescript

npm start not working

Maybe try using a folder than doesn't have space in the name. I don't know why that would cause issues but I can't think of any other reasons at this point.

iampeters

comment created time in 3 months

issue commentseanpmaxwell/express-generator-typescript

npm start not working

Hmmm I just walked through the steps and everything worked fine for me. Seems like you're doing things under something called iCould drive. Try doing it in a different folder like your desktop.

iampeters

comment created time in 3 months

issue commentseanpmaxwell/express-generator-typescript

npm start not working

you don't need to run npm install . I think you're using a different module mine is npx express-generator-typescript you just typed express-typescript-generator

iampeters

comment created time in 3 months

issue commentseanpmaxwell/express-generator-typescript

npm start not working

Did you do npm run build first?

iampeters

comment created time in 3 months

issue commentseanpmaxwell/overnight

Unable to access "this" inside controllers

Hey @joeykilpatrick Sorry to keep calling you but this is due to another change in your pull request and I think it's helpful to point it out.

This change right here on line 156:

let callBack: (...args: any[]) => any = controller[member];

is what was causing 'this' to be undefined. I reverted it back to:

let callBack = (req: Request, res: Response, next: NextFunction) => {
    return controller[member](req, res, next);
};

Please test all methods in the Sample Project before doing pull-requests. Everyone version 1.7.3 should fix this issue.

ryanpierre

comment created time in 3 months

issue closedseanpmaxwell/overnight

Question: TypeScript Configuration / getOwnMetadata() returns undefined

Hello,

I try to use this project for my next js-server application. I tried many things to got this to working but for whatever reason the metadata could not be readen.

As far as I understand the problem for me are the getRouter() implementation in the main Server.js file. Line 65 always returns undefined:

var classMetadata = Reflect.getOwnMetadata(types_1.classMetadataKey, prototype);

Maybe I messed up with the tsconfig. These are my current settings:

{
  "compilerOptions": {
    "target": "es6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
    "declaration": true,                   /* Generates corresponding '.d.ts' file. */
    "outDir": "./dist",                       /* Redirect output structure to the directory. */
    "baseUrl": "./",
    "importHelpers": true,                    /* Import emit helpers from 'tslib'. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
    "esModuleInterop": true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "experimentalDecorators": true,           /* Enables experimental support for ES7 decorators. */
    "emitDecoratorMetadata": true,            /* Enables experimental support for emitting type metadata for decorators. */
    "skipLibCheck": true,                     /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true  /* Disallow inconsistently-cased references to the same file. */
  }
}

For the demo purpose I used the example UserController.ts provided by the example application.

TypeScript: 3.9.2 Node: v14.1.0 npm: 6.14.4 @overnightjs/core 1.7.0

The readme says something about the lib property but no more information are given there -_- Many thanks for your support in advance.

Dennis

closed time in 3 months

dhemeier

issue commentseanpmaxwell/overnight

Question: TypeScript Configuration / getOwnMetadata() returns undefined

Please upgrade to 1.7.3 to make this problem go away

dhemeier

comment created time in 3 months

issue commentseanpmaxwell/overnight

AddControllers not working

Please upgrade to 1.7.3 there was also a bug where 'this' was being undefined

RobertoGlez

comment created time in 3 months

push eventseanpmaxwell/overnight

seanpmaxwell

commit sha 6af2bc4d0fd3a41dbf988e748cd926e3e32271e5

fixed bug this undefined

view details

push time in 3 months

IssuesEvent

issue commentseanpmaxwell/express-generator-typescript

Getting an error when calling "jsonwebtoken.verify"

those are equivalent

digizen

comment created time in 3 months

issue closedseanpmaxwell/overnight

AddControllers not working

I use "overnightjs" on my app structure, but controllers that create the routes not work, only on a specific computer, all routes give me 'Error Cannot GET /MyRoute', I have another computer where works fine literarly run the same code, is some a incompatibility?

Computer with Error: node: 12.16.3 typescript: 3.8.3 express: 4.17.1

closed time in 3 months

RobertoGlez

issue commentseanpmaxwell/overnight

AddControllers not working

Okay will close issue for now. But please reach out if something doesn't work.

RobertoGlez

comment created time in 3 months

issue commentseanpmaxwell/overnight

Question: TypeScript Configuration / getOwnMetadata() returns undefined

Let me know if version 1.7.2 fixes the issue.

dhemeier

comment created time in 3 months

issue commentseanpmaxwell/overnight

AddControllers not working

Hey @joeykilpatrick sorry to call you out but your change on line 151 broke things:

for (const member in controller) {

This only loops though the instance-object properties and skips the prototype ones. I changed this part back to

        let members: any = Object.getOwnPropertyNames(controller);
        members = members.concat(Object.getOwnPropertyNames(prototype));
        members.forEach((member: any) => {

I updated Overnight to version 1.7.2 now

RobertoGlez

comment created time in 3 months

push eventseanpmaxwell/overnight

seanpmaxwell

commit sha 3b801b5dbcd9e216dd97421bc11f7d977b2f59c6

fixed bug functions not getting looped

view details

push time in 3 months

issue closedseanpmaxwell/express-generator-typescript

Getting an error when calling "jsonwebtoken.verify"

Just ran the generator. The generated app is throwing an error src/shared/JwtService.ts - the jsonwebtoken.verify has parameters that aren't matching.

I'm running Win10, Node v12, Typescript 3.6.3.

The error message:

`src/shared/JwtService.ts:45:51 - error TS2769: No overload matches this call. Overload 1 of 3, '(token: string, secretOrPublicKey: Secret, options?: VerifyOptions | undefined): string | object', gave the following error. Type '(err: VerifyErrors, decoded: string | object) => void' has no properties in common with type 'VerifyOptions'. Overload 2 of 3, '(token: string, secretOrPublicKey: string | Buffer | { key: string | Buffer; passphrase: string; } | GetPublicKeyOrSecret, callback?: VerifyCallback | undefined): void', gave the following error. Argument of type '(err: VerifyErrors, decoded: object | string) => void' is not assignable to parameter of type 'VerifyCallback'. Types of parameters 'err' and 'err' are incompatible. Type 'JsonWebTokenError | NotBeforeError | TokenExpiredError | null' is not assignable to type 'VerifyErrors'. Type 'null' is not assignable to type 'VerifyErrors'. Overload 3 of 3, '(token: string, secretOrPublicKey: string | Buffer | { key: string | Buffer; passphrase: string; } | GetPublicKeyOrSecret, options?: VerifyOptions | undefined, callback?: VerifyCallback | undefined): void', gave the following error. Type '(err: VerifyErrors, decoded: string | object) => void' has no properties in common with type 'VerifyOptions'.

45 jsonwebtoken.verify(jwt, this.secret, (err: VerifyErrors, decoded: object | string) => { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

at createTSError (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:434:12)
at reportTSError (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:438:19)
at getOutput (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:578:36)
at Object.compile (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:775:32)
at Module.m._compile (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:858:43)
at Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Object.require.extensions.<computed> [as .ts] (C:\code\js\fullstack_express\express_test\node_modules\ts-node\src\index.ts:861:12)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)`

closed time in 3 months

digizen

issue commentseanpmaxwell/overnight

AddControllers not working

Version 1.7.1 is published let me know if it works for you

RobertoGlez

comment created time in 3 months

issue commentseanpmaxwell/overnight

Question: TypeScript Configuration / getOwnMetadata() returns undefined

Hmm i made sure to tsc before publishing. I thought that would overwrite all old files. I deleted .d.ts and .js and .js.map files this time and re-ran tsc. Try again everyone.

dhemeier

comment created time in 3 months

push eventseanpmaxwell/overnight

seanpmaxwell

commit sha 06c830cca3dd6be5932e5a4a9cf05dc2c0526611

fix metadata undefined bug

view details

push time in 3 months

push eventseanpmaxwell/overnight

seanpmaxwell

commit sha 74eaa65946e0363bf09cd294f6b4d14b36875bc8

updated sample projects tsconfig

view details

push time in 3 months

issue commentseanpmaxwell/overnight

Question: TypeScript Configuration / getOwnMetadata() returns undefined

Here's my tsconfig.json. Try with this and see if it helps. I'm not able to reproduce the issue. But I did notice some differences in our tsconfigs.

	{
  "compilerOptions": {
    "baseUrl": "./",
   	{
  "compilerOptions": {
    "baseUrl": "./",
    "emitDecoratorMetadata": true,
    "declaration": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "removeComments": true,
    "strict": true,
    "target": "es6",
    "types": [
      "node"
    ],
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "**/node_modules/"
  ]
}
    "declaration": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "removeComments": true,
    "strict": true,
    "target": "es6",
    "types": [
      "node"
    ],
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "**/node_modules/"
  ]
}
dhemeier

comment created time in 3 months

issue commentseanpmaxwell/express-generator-typescript

Getting an error when calling "jsonwebtoken.verify"

Hey thanks so much for pointing this out. I neglected to use the --with-auth option last time. The callback for the jsonwebtoken library was updated so the callback being passed to it stopped working. I updated express-generator-typescript to a new version. Try it now and let me know if it works for you so I can close this.

digizen

comment created time in 3 months

push eventseanpmaxwell/express-generator-typescript

seanpmaxwell

commit sha 71a01d6f7a2d5329ddb802648609d6a187d28c54

fixed a bug for new jsonwebtoken module callback

view details

push time in 3 months

issue commentseanpmaxwell/express-generator-typescript

Getting an error when calling "jsonwebtoken.verify"

and you downloaded express-generator-typescript with npx express-generator-typescript?

digizen

comment created time in 3 months

issue commentseanpmaxwell/express-generator-typescript

Getting an error when calling "jsonwebtoken.verify"

I just ran it and it worked fin for me. Did you use npm run start:dev? I'm on node v12.13.0

digizen

comment created time in 3 months

issue closedseanpmaxwell/overnight

Set prefix in all controllers

I have the same problem this issue https://github.com/seanpmaxwell/overnight/issues/48.

Only I'm using inversify to inject the services into my controllers, so I can't use a parent controller.

ControllerExample.ts

import { Controller, Get, Middleware } from '@overnightjs/core'
import { injectable, inject } from 'inversify'

import TYPES from '@src/ioc/types'

import BannerService from './BannerService'

@injectable()
@Controller('banner')
class BannerController {
  private bannerService: BannerService

  constructor(@inject(TYPES.BannerService) bannerService: BannerService) {
    this.bannerService = bannerService
  }
}

export BannerController

Server.ts

import DIContainer from './ioc'
import TYPES from './ioc/types'
import BannerController from './modules/banner/BannerController'
...
const bannerController = DIContainer.get<BannerController>(TYPES.BannerController)
super.addControllers([bannerController])

closed time in 3 months

ivanguimam

issue commentseanpmaxwell/overnight

Set prefix in all controllers

Closing issue

ivanguimam

comment created time in 3 months

issue closedseanpmaxwell/overnight

controllers does not support multiple method

If I tried to make route to work on both Post and Get. It does not work either I get @post or @get to work in one time.

@Post() @Get() public async method(req: Reqest, res: Response) { }

closed time in 3 months

MuBoori

issue commentseanpmaxwell/overnight

controllers does not support multiple method

Merged @joeykilpatrick's pull request. Sorry for taking so long.

MuBoori

comment created time in 3 months

pull request commentseanpmaxwell/overnight

Added Mocha tests for core with 100% coverage using Istanbul

Oh yeah, I just updated the @types/express library is bother core and sample project and it's fixed. I redeployed overnight. Version for core is now 1.7.0

joeykilpatrick

comment created time in 3 months

push eventseanpmaxwell/overnight

seanpmaxwell

commit sha 242ba2d4a2893e0d04a2afaf33ff7cc85fce6e50

merge with pull request for mocha tests and updated express types

view details

push time in 3 months

push eventseanpmaxwell/overnight

Joey Kilpatrick

commit sha 7b141b632986690e5148757863460af761e179e0

Un-ignored package-lock.json files and added tslib to sample-project

view details

Sean Maxwell

commit sha cb811f84c2a90fe07d9e8df2d941824ccc25a912

Merge pull request #55 from joeykilpatrick/master Un-ignored package-lock.json files and added tslib to sample-project

view details

push time in 3 months

pull request commentseanpmaxwell/overnight

Added Mocha tests for core with 100% coverage using Istanbul

Hey your changes broke the sample project in CustomRouterServer. Please fix before I update the library. super.addControllers(new CustomRouterController(), customRouter);

Types of parameters 'handler' and 'handler' are incompatible. Types of parameters 'req' and 'req' are incompatible. Type 'import("c:/Projects/Overnight/sample-project/node_modules/@types/express-serve-static-core/index").Request' is not assignable to type 'import("c:/Projects/Overnight/src/core/node_modules/@types/express-serve-static-core/index").Request'.

joeykilpatrick

comment created time in 3 months

push eventseanpmaxwell/overnight

Joey Kilpatrick

commit sha 132006fd8a7201a18c6449090e16f99058d1717e

Broke up decorators into individual files for cleaner commits

view details

Joey Kilpatrick

commit sha 3ee59e45652dfa7443e32ce9ae4149129b2534c8

Added typescript in devDependencies for core

view details

Joey Kilpatrick

commit sha 5d674de99eac21cfb04b092534d233c4005e250c

Moved common reflection code to helper method

view details

Joey Kilpatrick

commit sha 121f31729565cb06963bbbc1792c0b734cef37fb

Combined middleware and errorMiddleware files

view details

Joey Kilpatrick

commit sha f7db76e09a1561bc917ee68e64b7590a77c0aa6f

Removed tslint rule 'ban-types' (it had been ignored 12 times)

view details

Joey Kilpatrick

commit sha c0859b46b27816c287b995c1b4bfe7da996b53af

Moved ClassKeys enum to types.ts and added HttpVerb enum

view details

Joey Kilpatrick

commit sha 48a3dd86b657970d350b9863befa1a89e4948fb2

Moved Class Middleware and Wrapper functions to middleware.ts and wrapper.ts respectively

view details

Joey Kilpatrick

commit sha 9a144bfb1420f699359bb81bd5aef4d175bd05e9

Narrowed type definitions for method decorators to 'MethodDecorator & PropertyDecorator'

view details

Joey Kilpatrick

commit sha a4b72a15436b5cfe19ed00044436f1e5a71b0efb

Added Mocha tests with 99% coverage using Istanbul

view details

Joey Kilpatrick

commit sha 3c87db0de8db3c561f40b0c20c1ed10745bbc615

Allow @ErrorMiddleware to also take in an array of ErrorMiddleware (uncommented tests for this)

view details

Joey Kilpatrick

commit sha aed5842dbf8218c64b8ebcb28531dd3dcab8d724

Added @All method decorator to use for all HTTP verbs

view details

Joey Kilpatrick

commit sha 7f8854244c8055f08e53f97bf20fb8142bef9a42

Allow multiple HTTP verb decorators on a method

view details

Joey Kilpatrick

commit sha 67b836e5ca43a0d2edf75f5347eb75e0bcfcad29

Imported mocha in *.spec.ts explicitly

view details

Joey Kilpatrick

commit sha dc59d2f409001242122301b570f4da7b65bd6b40

Refactored types of all objects in core and enforced strict typing

view details

Joey Kilpatrick

commit sha 377d6f2357bfe4fa8f824eccf91f83b1ed6d3e48

Made tests conform to strict typing

view details

Joey Kilpatrick

commit sha 19f9fa84a3df31c5a90f7af7378b632eb8ea554e

Fixed issue with wrapping methods with more than 3 arguments

view details

Joey Kilpatrick

commit sha 2e56190447fa7c1aa7a3161e24bc12d34e112122

Added tests to achieve 100% coverage

view details

Joey Kilpatrick

commit sha 8c8671eb51b12414f9874e4b5b9440de31511601

Merged and added coverage for global middleware

view details

Sean Maxwell

commit sha a64632b74319adb0e5f1a74065f48b941025d0f1

Merge pull request #41 from joeykilpatrick/master Added Mocha tests for core with 100% coverage using Istanbul

view details

push time in 3 months

PR merged seanpmaxwell/overnight

Added Mocha tests for core with 100% coverage using Istanbul

Other changes to core

  • Broke up decorators.ts into individual files for easier testing
  • Refactored to enforce strict typing throughout
  • Added npm run lint command to run tslint over all files
  • Added npm run test command to run Mocha tests
  • Added npm run coverage command to run tests and generate console and HTML coverage reports
  • Allowed @ErrorMiddleware to also take in an array of ErrorMiddleware
  • Added @All decorator to use a method for all HTTP verbs
  • Added support for multiple @VERB decorators on a method
  • Closed #42
+3292 -374

4 comments

38 changed files

joeykilpatrick

pr closed time in 3 months

issue closedseanpmaxwell/overnight

Wrapper does not work when method has more than 3 parameters

I'm not sure if this is a bug or an unimplemented feature.

Version: 1.6.14

Clearly if @Wrapper(...) is not used on a method, then the method must be of type (req: Request, res: Response) => any to work. However, if @Wrapper(func) is defined, then the method method(...) really could be of any type, as long as func(method) is of type (req: Request, res: Response) => any.

Currently, if method(...) has up to three parameters, this works. However, if method(...) has more than three parameters, then the method returns null.

Consider the following:

@Controller('path')
export class BigWrapperController {

    @Get('3args')
    @Wrapper(returnAsMessage(1, 1, 1))
    sum3(num1: number, num2: number, num3: number): number {
        return num1 + num2 + num3;
    }

    @Get('4args')
    @Wrapper(returnAsMessage(1, 1, 1, 1))
    sum4(num1: number, num2: number, num3: number, num4: number): number {
        return num1 + num2 + num3 + num4;
    }

}

/**
 * Wrapper that passes its arguments to the method and then handles the
 * request with a 200 status code and the method's return value as a
 * message in the response body.
 * @param args Arguments to be passed to the method
 */
function returnAsMessage(...args: any) {
    return (method: Function): RequestHandler => {
        return (req: Request, res: Response): Response => {
            return res.status(200).json({
                message: method(...args)
            })
        }
    }
}

When calling the route /path/3args, the response is:

{
    message: 3
}

When calling the route /path/4args, the response is:

{
    message: null // Should be 4
}

Code to reproduce is linked here.

closed time in 3 months

joeykilpatrick

issue commentmicrosoftgraph/microsoft-graph-docs

cannot find Java example for uploading file to share-point online site using MS graph Java SDK

I need a full example that's in Java and uploading a PDF to sharepoint. Those examples are only bits and pieces of Java code.

bdv1234

comment created time in 3 months

issue commenteslint/eslint

Enforce 2 (or more) lines not just one [lines-between-class-members]

Would be awesome if implemented. tslint-lines-between-class-members is still growing in npm downloads so def would be useful to a lot of people if implemented.

seanpmaxwell

comment created time in 3 months

pull request commenteslint/eslint

Update: rule 'padding-line-between-statements' - add number of lines

Any chance this pull request could be modified to enforce for 2 or more lines between class members?

IgorNovozhilov

comment created time in 3 months

issue commenteslint/eslint

Enforce 2 (or more) lines not just one [lines-between-class-members]

Ideally I would like it to be configured just tslint-lines-between-class-members found here https://github.com/chinchiheather/tslint-lines-between-class-members#readme. So true means the rule is being enforced.

seanpmaxwell

comment created time in 3 months

pull request commenteslint/eslint

Update: rule 'padding-line-between-statements' - add number of lines

Can this be used to enforce 2 lines between class members?

IgorNovozhilov

comment created time in 3 months

pull request commentseanpmaxwell/overnight

Added Mocha tests for core with 100% coverage using Istanbul

Sorry I really need to get around to this. I haven't reviewed the changes but now that someone else has approved I should just implement it.

joeykilpatrick

comment created time in 3 months

startedeslint/eslint

started time in 3 months

issue openedeslint/eslint

Enforce 2 (or more) lines not just one [lines-between-class-members]

<!-- ESLint adheres to the Open JS Foundation Code of Conduct: https://eslint.org/conduct

This template is for requesting a rule change. If you are here for another reason, please see below:

1. To report a bug: https://eslint.org/docs/developer-guide/contributing/reporting-bugs
2. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
4. If you have any questions, please stop by our chatroom: https://eslint.org/chat

Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.

-->

What rule do you want to change?

[lines-between-class-members]

Does this change cause the rule to produce more or fewer warnings?

Possibly more.

How will the change be implemented? (New option, new default behavior, etc.)?

Modification to setting in eslint file.

{
  "rules": {
    "lines-between-class-members": [true, 2], <--- This right here, enforces 2 lines
  },
  "rulesDirectory": [
    "node_modules/tslint-lines-between-class-members"
  ]
}

Please provide some example code that this change will affect:

<!-- Put your code examples here -->

// Valid
    componentDidMount() {
        this._isMounted = true;
        this.getProjects();
        this.getPendingInvites();
    }

    
    componentWillUnmount() {
        this._isMounted = false;
    }

// Invalid

    componentDidMount() {
        this._isMounted = true;
        this.getProjects();
        this.getPendingInvites();
    }
    
   componentWillUnmount() {
        this._isMounted = false;
    }

What does the rule currently do for this code?

Can only be used to enforce 1 space between class members.

What will the rule do after it's changed?

Be able to enforce more than 1 space. Some people like to use 2 spaces.

Are you willing to submit a pull request to implement this change?

No I don't know how this works under the hood.

created time in 3 months

more