-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
566 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ install: | |
- yarn install | ||
|
||
build_script: | ||
- npm run build | ||
- nps build | ||
|
||
test_script: | ||
- npm test | ||
- nps test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as _ from 'lodash'; | ||
import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments } from 'class-validator'; | ||
|
||
|
||
@ValidatorConstraint({ name: 'endsWith', async: false }) | ||
export class EndsWithValidator implements ValidatorConstraintInterface { | ||
|
||
public validate(text: string, args: ValidationArguments): boolean { | ||
for (const ending of args.constraints) { | ||
if (_.endsWith(text, ending)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public defaultMessage(args: ValidationArguments): string { | ||
return 'Incorrect suffix'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* config.Custom | ||
* ------------------------------------ | ||
* | ||
* Define all log adapters for this application and chose one. | ||
*/ | ||
|
||
import * as express from 'express'; | ||
import * as uuid from 'uuid'; | ||
|
||
import { Logger } from '../core/Logger'; | ||
import { App, Configurable } from '../core/App'; | ||
import { Environment } from '../core/helpers/Environment'; | ||
|
||
|
||
export class CustomHeaderConfig implements Configurable { | ||
|
||
private log = new Logger(__filename); | ||
|
||
public configure(app: App): void { | ||
this.log.debug('Add custom headers'); | ||
|
||
app.Express.use((req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
res.setHeader('X-API-VERSION', Environment.getPkg().version); | ||
res.setHeader('X-Request-Id', uuid.v4()); | ||
next(); | ||
}); | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* MakeValidatorCommand | ||
* ------------------------------------- | ||
* | ||
*/ | ||
import { AbstractMakeCommand } from './lib/AbstractMakeCommand'; | ||
|
||
|
||
export class MakeValidatorCommand extends AbstractMakeCommand { | ||
|
||
public static command = 'make:validator'; | ||
public static description = 'Generate new validator'; | ||
|
||
public type = 'Validator'; | ||
public suffix = 'Validator'; | ||
public template = 'validator.hbs'; | ||
public target = 'api/validators'; | ||
public updateTargets = false; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments } from 'class-validator'; | ||
|
||
|
||
@ValidatorConstraint({ name: '{{name.normal}}', async: false }) | ||
export class {{name.capitalize}}Validator implements ValidatorConstraintInterface { | ||
|
||
public validate(text: string, args: ValidationArguments): boolean { | ||
// Place your validation here | ||
return true; | ||
} | ||
|
||
public defaultMessage(args: ValidationArguments): string { | ||
// Error message if the validation fails | ||
return 'Incorrect value'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as basicAuth from 'express-basic-auth'; | ||
|
||
|
||
export const BasicAuthentication = (): any => { | ||
return basicAuth({ | ||
users: { | ||
[process.env.APP_BASIC_USER]: process.env.APP_BASIC_PASSWORD | ||
}, | ||
challenge: true | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.