Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('babel-register')
var app = require('express')()
var serveStatic = require('serve-static')
var ejs = require('consolidate').ejs
var routes = require('./routes')
app.engine('html', ejs)
app.set('view engine', 'html')
app.set('views', '.')
// Register routes
routes(app)
// Serve static assets
app.use('/static', serveStatic('.'))
// Start server
app.listen('1234', function () {
console.log('Listening on 1234')
})
var app = require('express')();
var serveStatic = require('serve-static');
var ejs = require('consolidate').ejs;
var routes = require('./routes');
app.engine('html', ejs);
app.set('view engine', 'html');
app.set('views', 'templates');
// Register routes on child app
routes(app);
// Serve static assets on base app
app.use('/static', serveStatic('.'));
// Start server
app.listen('1234', function () {
console.log('Listening on 1234');
});
registerViewEngine: function () {
// Set up view engine and static files for pages
var app = this.app;
app.engine('ejs', ejsEngine);
app.engine('jade', jadeEngine);
app.set('view engine', 'ejs');
app.set('views', __dirname + '/views');
app.use('/public', express['static'](__dirname + '/../dist'));
app.use('/public', express['static'](__dirname + '/../public'));
app.use(expressPartials());
},
addRoutes: function () {
context.labStorageSnapshotId = undefined;
}
if (course.share.find(x => x === "labMaterialSnapshotId")) {
context.labMaterialSnapshotId = course.labMaterialSnapshotId;
context.labMaterialSnapshotUrl = `https://${region}.console.aws.amazon.com/ec2/v2/home?region=${region}#Snapshots:visibility=private;search=${context.labMaterialSnapshotId}`;
}
if (course.share.find(x => x === "imageId")) {
context.imageId = course.imageId;
context.imageIdUrl = `https://${region}.console.aws.amazon.com/ec2/v2/home?region=${region}1#Images:visibility=private-images;search=${context.imageId}`;
}
if (course.share.find(x => x === "endLabAmi")) {
context.endLabImageIdUrl = `https://${region}.console.aws.amazon.com/ec2/v2/home?region=${region}#Images:visibility=private-images;imageId=${context.endLabAmi}`;
}
cons.ejs(__dirname + '/template/endLabEmail.ejs', context)
.then((template) => {
context.emailBody = template;
resolve(context);
})
.catch((err) => {
reject(err);
});
});
let bindTemplate = context => new Promise((resolve, reject) => {
let emailContext = context;
emailContext.signInUrl = `https://${awsAccountId}.signin.aws.amazon.com/console`;
emailContext.instanceInUrl = `https://${region}.console.aws.amazon.com/ec2/v2/home?region=${region}#Instances:instanceId=${emailContext.id};sort=instanceId`;
cons.ejs(__dirname + '/template/userEmail.ejs', emailContext)
.then((template) => {
emailContext.emailBody = template;
resolve(emailContext);
})
.catch((err) => {
reject(err);
});
});
return new Promise((resolve, reject) => {
console.log('Create bindBackupCfnTemplate');
cons.ejs('template/backupLabStorage.yaml', context)
.then(template => {
resolve(template);
})
.catch(err => {
reject(err);
});
});
}
app.get('/:alias', (req, res) => {
const templates = this.compileTemplatesFromFolder(directory);
const template: any = find(templates, { Alias: req.params.alias });
consolidate.ejs(
this.previewTemplate,
{ template: template },
(err, html) => {
if (err) res.send(err);
return res.send(html)
}
)
});
return new Promise((resolve, reject) => {
cons.ejs(path, context)
.then(template => {
resolve("" + template);
})
.catch(err => {
reject(err);
});
});
}
app.get('/', (req, res) => {
manifest = createManifest(templatesdirectory)
const templates = filter(manifest, { TemplateType: 'Standard' })
const layouts = filter(manifest, { TemplateType: 'Layout' })
const path = untildify(templatesdirectory).replace(/\/$/, '')
consolidate.ejs(
`${previewPath}index.ejs`,
{ templates, layouts, path },
(err, html) => renderTemplateContents(res, err, html)
)
})
app.get('/', (req, res) => {
const templates = this.compileTemplatesFromFolder(directory);
consolidate.ejs(
this.previewRoot,
{
templates: filter(templates, { TemplateType: 'Standard' }),
layouts: filter(templates, { TemplateType: 'Layout' }),
path: this.fileUtils.directoryFullPath(directory),
},
(err, html) => {
if (err) res.send(err);
return res.send(html);
}
)
});