Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function bootstrapContainers() {
// let's tell orm and the routing controller to use the typeDI
// https://github.com/typestack/typedi/issues/4
ormUseContainer(Container);
routingUseContainer(Container);
}
async function boot(port: number, addr: string) {
// Tell routing-controller to use our dependency injection container
useContainer(Container);
// Wires all dependencies
const vaultPath = storagePath(VAULT_FILENAME, program.data);
Container.set('cipherLocation', vaultPath);
await loadConfig(true);
Container.set(DatabaseWithAuth, Container.get(JSONDatabaseWithAuth));
// Create an express server which is preconfigured to serve the API
const server = createVaultageAPIServer();
// Bind static content to server
const pathToWebCliGUI = path.dirname(require.resolve('vaultage-ui-webcli'));
const staticDirToServer = path.join(pathToWebCliGUI, 'public');
server.use(express.static(staticDirToServer));
import * as path from 'path';
import * as config from 'config';
import * as log4js from 'log4js';
import 'source-map-support/register';
import { createConnection, useContainer as useContainerForOrm } from 'typeorm';
import { Container } from 'typedi';
import { createExpressServer, useContainer as useContainerForRouting } from 'routing-controllers';
import fileUtils from './core/file-utils';
const packagejson = require('../package.json');
// log4jsを初期設定
log4js.configure(config['log4js']);
// TypeORM, TypeDIを初期化
useContainerForOrm(Container);
useContainerForRouting(Container);
const options = Object.assign({}, config['database']);
options['logging'] = ['query', 'error'];
options['entities'] = [
__dirname + '/entities/{*.ts,*.js}'
];
createConnection(options).then(() => {
// Expressサーバー作成
const app = createExpressServer({
routePrefix: '/api',
controllers: [__dirname + '/controllers/*.js'],
middlewares: [__dirname + '/middlewares/*.js'],
});
// log4jsでアクセスログ出力設定
app.use(log4js.connectLogger(log4js.getLogger('access'), {
level: 'auto',
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var routing_controllers_1 = require("routing-controllers");
var typedi_1 = require("typedi");
var index_1 = require("./controllers/index");
require("reflect-metadata");
routing_controllers_1.useContainer(typedi_1.Container);
var app = routing_controllers_1.createExpressServer({
controllers: [
index_1.IntroController,
index_1.UserController,
index_1.TestController
]
});
var port = process.env.PORT || 1111;
app.listen(port, function () {
console.log("The server is starting at http://localhost:" + port);
});
//# sourceMappingURL=app.js.map
import { createExpressServer, useContainer } from 'routing-controllers';
import { Container } from 'typedi';
import { IntroController, UserController } from './controllers/index';
import 'reflect-metadata';
useContainer(Container);
const app = createExpressServer({
controllers: [
IntroController,
UserController,
]
});
const port = process.env.PORT || 1111;
app.listen(port, () => {
console.log(`The server is starting at http://localhost:${port}`);
});
export const createServer = async(): Promise => {
const koa: Koa = new Koa()
useMiddlewares(koa)
const app: Koa = useKoaServer(koa, routingConfigs)
useContainer(Container)
return app
}
import { middlewares } from './middlewares'
import { Container, Token } from 'typedi'
import {
appAuthAccessTokenKey,
appAuthIdTokenKey
} from '../../client/app/app.module'
import { auth0ServerValidationNoAngularFactory, azNoAngular } from './helpers'
import * as express from 'express'
import * as bodyParser from 'body-parser'
import { map } from 'rxjs/operators'
import { AuthOptions } from 'auth0-js'
const swaggerJSDoc = require('swagger-jsdoc')
const swaggerUi = require('swagger-ui-express')
useContainer(Container)
export type Auth0Config = AuthOptions
export type SendGridAPIKey = string
export type Auth0Cert = string
export const AUTH0_MANAGEMENT_CLIENT_CONFIG = new Token()
export const SENDGRID_API_KEY = new Token()
export const AUTH0_CERT = new Token()
Container.set(
AUTH0_CERT,
process.env.AUTH0_CERT && process.env.AUTH0_CERT.replace(/\\n/g, '\n')
)
Container.set(SENDGRID_API_KEY, process.env.SENDGRID_API_KEY)
Container.set(AUTH0_MANAGEMENT_CLIENT_CONFIG, {
domain: process.env.AUTH0_DOMAIN || '',
clientID: process.env.AUTH0_CLIENT_ID || ''
import * as cors from "koa2-cors"
import * as jwt from "koa-jwt"
import {Action} from "routing-controllers/Action"
import {Container} from "typedi"
import {TodoController} from "./controllers/todo.controller"
import {HomeController} from "./controllers/home.controller"
import {EvaluateController} from "./controllers/evaluate.controller"
useContainer(Container)
export const createHttpServer = async () => {
const koa = new Koa()
if (Environment.identity !== 'production') koa.use(json())
koa.use(cors())
koa.use(jwt({
secret: Environment.jwtSecret
}).unless({
path: [
/\/api\/login/,
/\/api\/share\/./,
import "reflect-metadata";
import {createKoaServer, useContainer} from "routing-controllers";
import {Container} from "typedi";
import {CategoryController} from "./controllers/CategoryController";
import {PostController} from "./controllers/PostController";
/**
* Setup routing-controllers to use typedi container.
*/
useContainer(Container);
/**
* We create a new koa server instance.
* We could have also use useKoaServer here to attach controllers to an existing koa instance.
*/
const koaApp = createKoaServer({
/**
* We can add options about how routing-controllers should configure itself.
* Here we specify what controllers should be registered in our express server.
*/
controllers: [
CategoryController,
PostController
]
});