Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
})
server.get('/gallery', (req, res) => {
gallery.getAllPhotos(req, (err, data) => {
res.setHeader('content-type', 'application/json')
if (err) {
res.send(400, {status: 'error', message: err.message })
} else {
res.send(202, {status: 'success', message: 'gallery retrieved', data: data})
}
})
})
/* we set up a route to serve static files from the 'photos/' directory. */
server.get(/photos\/?.*/, restify.serveStatic({
directory: __dirname
}))
var port = process.env.PORT || 8080
server.listen(port, function (err) {
if (err) {
console.error(err)
} else {
console.log('App is ready at : ' + port)
}
})
appId: process.env.BOTFRAMEWORK_APPID,
appSecret: process.env.BOTFRAMEWORK_APPSECRET
};
// Create bot and add dialogs
var bot = new builder.BotConnectorBot(botConnectorOptions);
bot.add('/', function (session) {
session.send('Hello World');
});
// Setup Restify Server
var server = restify.createServer();
server.post('/api/messages', bot.verifyBotFramework(), bot.listen());
// Serve a static web page
server.get(/.*/, restify.serveStatic({
'directory': '.',
'default': 'index.html'
}));
server.listen(process.env.port || 1337, function () {
console.log('%s listening to %s', server.name, server.url);
});
server.listen(opt.port || CONFIG.server.port, () => {
if (verbose) info('Server "' + server.name + '" listening to ' + server.url);
// Serve static files
let root = process.cwd() + '/webapp/';
if (verbose) info("Serve static files on "+ root);
server.get(/\/static\/?.*/, restify.serveStatic({
directory: root,
default: 'index.html',
charSet: 'utf-8',
}));
callback(undefined, server);
});
}
module.exports = function(server) {
/************** file module ****************/
server.get('/files', files_module.get_files); //tested
server.get('/run_file/:id', files_module.run_file); //tested
server.post('/upload',files_module.upload_file); //tested
/************** status module ****************/
server.get('/status', status_module.get_status); //tested
/************** commands module ****************/
server.get('/stop',commands_module.stop);
// Define the routes
server.get(/.*/, restify.serveStatic({
directory: './static'
}));
};
// ----------------------------------------------
server.get('/api/:url', function (req, res, next) {
var body = 'something';
res.writeHead(200, {
'Content-Length': Buffer.byteLength(body),
'Content-Type': 'text/html'
});
res.write(body);
res.end();
return next();
});
// Static files
server.get(/\/sources\/?.*/, restify.serveStatic({
directory: '../'//__dirname
}));
server.get(/\/test\/?.*/, restify.serveStatic({
directory: '../'//__dirname
}));
// ----------------------------------------------
var wrench = require("wrench");
var uglify = require("uglify-js");
var path = require('path');
var walk = function(dir, done) {
var results = [];
fs.readdir(dir, function(err, list) {
SessionServer.prototype.static = function(_path, _config) {
//if(this.isStarted){
this.server.get(_path, restify.serveStatic(_config));
//}else{
// this.methods.staticFiles[_path] = _config;
//}
};
module.exports = app; // for testing
var config = {
appRoot: __dirname // required config
};
app.use(
function crossOrigin(req,res,next){
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
return next();
}
);
app.get('/', restify.serveStatic({
directory: './build/mineranker',
default: 'index.html'
}));
app.get(/\/.*\..*/, restify.serveStatic({
directory: './build/mineranker',
default: 'index.html'
}));
SwaggerRestify.create(config, function(err, swaggerRestify) {
if (err) {
throw err;
}
swaggerRestify.register(app);
server.get('/all/account', get_response.findAllAccount);
server.get('/account/id/:id', get_response.getAccountById);
server.get('/account/name/:name', get_response.getAccountByName);
server.post('/account/create', auth.create);
server.post('/login/user', auth.login);
server.get('/all/rice', rice.findAllRice);
server.post('/rice/create', rice.create);
server.get('/', restify.serveStatic({
directory: 'web',
default: 'index.html'
}));
server.get(/\/?.*/, restify.serveStatic({
directory: 'web'
}));
server.listen(8080, function () {
'use strict';
console.log('%s listening at %s', server.name, server.url);
});
console.log('POST /accounts')
const auth = req.authorization
const body = req.body
console.log(body)
const host = req.headers.host
console.log(typeof req.files)
accounts.add(host, auth, body, req.files, function(data) {
console.log('DATA RETURNED')
console.log(data)
res.setHeader('content-type', 'application/json');
res.send(data.code, data.response);
res.end();
})
})
server.get(/images\/?.*/, restify.serveStatic({
directory: __dirname
}))
fs.mkdir('images', function(err) {
if (err) {
console.log('error creating images directory')
}
console.log('images directory created')
})
var port = process.env.PORT || 8080;
server.listen(port, function (err) {
if (err) {
console.error(err);
} else {
console.log('App is ready at : ' + port);
module.exports = function(server) {
server.post('/apps', submitApp);
server.get('/apps', getApps);
server.get('/apps/:id', getAppInfo);
server.get('/apps/:id/config', getAppConfig);
server.post('/apps/:id/config', postAppConfig);
server.del('/apps/:id', deleteApp);
server.get('/apps/:id/files', listAppFiles);
server.get(/\/approot\/?.*/, restify.serveStatic({
directory: config.getDataDir('approot'),
}));
server.get('/updater', updater);
};