Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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));
// run application on port port
server.listen(port, addr, () => {
console.log(`Server is listening on port ${port}`);
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));
// run application on port port
server.listen(port, addr, () => {
console.log(`Server is listening on port ${port}`);
});
}
public static bindToServer(expressApp: Application, initialConfig?: VaultageConfig ) {
if (initialConfig) {
Container.set('config', initialConfig);
}
// registers our routes (present in Cipher/ConfigController) on this express server
useExpressServer(expressApp, {
controllers: [
CipherController,
ConfigController
]
});
}
}
it('With Through and options', (cb) => {
const Model = () => Object
const Through = () => Object
const options = { name: "TestTest" }
const mock = new RelayedQueryService()
Container.set(RelayedQueryService, mock)
RelayedQuery(Model, Through, options)(TestClass.prototype, 'test', {} as any)
process.nextTick(() => {
const makeMethodRelayed = mock.makeMethodRelayedQuery as jest.Mock
expect(makeMethodRelayed).toHaveBeenCalledTimes(1)
expect(makeMethodRelayed.mock.calls).toContainAllValues([
[
TestClass.prototype,
'test',
{},
Model,
Through,
options
]
])
cb()
export default function preFn(gitPath: string, { terminal }: ICliOptions) {
if (existsSync(gitPath)) {
const dirArray = readdirSync(gitPath);
if (dirArray.indexOf(".git") !== -1) {
const getTerm = terminal ? terminal : null;
if (typeof getTerm === "boolean") {
console.log("Please set the type of terminal encoding");
} else {
Container.set("terminal", getTerm);
Container.set("git-path", gitPath);
Container.set("terminal-size", { width: process.stdout.columns, height: process.stdout.rows });
const sc = Container.get(Screen);
sc.initStateAndRender();
}
} else {
console.log("This is not a git repository");
}
} else {
console.log("Wrong path");
}
}
if ((config as AutoRelayConfigArgsExistingModel).objects) {
this._declareExistingObjects(config as AutoRelayConfigArgsExistingModel)
} else {
const configNoModel: AutoRelayConfigArgsNoModel = config;
configNoModel.microserviceName = configNoModel.microserviceName ? String(configNoModel.microserviceName) : ''
if ( configNoModel.microserviceName) {
configNoModel.microserviceName = configNoModel.microserviceName![0].toUpperCase() + configNoModel.microserviceName!.substring(1)
}
AutoRelayConfig.generateObjects(config, true)
Container.set(PREFIX, configNoModel.microserviceName)
if (configNoModel.extends && configNoModel.extends.connection) {
Container.set(CONNECTION_BASE_OBJECT, configNoModel.extends.connection)
} else {
Container.set(CONNECTION_BASE_OBJECT, () => Object)
}
}
AutoRelayConfig._config = config
}
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 || ''
} as AuthOptions)
export const useApi = (app: express.Application) => {
const swaggerSpec = swaggerJSDoc({
swaggerDefinition: {
info: {
title: 'fusing-angular',
description: '',
termsOfService: '',
contact: {
name: 'Patrick Michalina',
url: 'https://github.com/patrickmichalina/fusing-angular/issues',
email: 'patrickmichalina@mac.com'
},
models.forEach(m => {
Container.set(m.name, m.model);
});
protected _declareExistingObjects(config: AutoRelayConfigArgsExistingModel): void {
Container.set(PAGINATION_OBJECT, config.objects.pageInfo)
Container.set(CONNECTIONARGS_OBJECT, config.objects.connectionArgs)
}