Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
}
// set you cache maximum age, in milisecconds.
// if you don't use cache break use a smaller value
var oneMonth = 1000 * 60 * 60 * 24 * 30;
// start the server
var server = connect.createServer(
// good ol'apache like logging
// you can customize how the log looks:
// http://senchalabs.github.com/connect/middleware-logger.html
connect.logger(),
// call to trigger routes
connect.router(routes),
// set to ./ to find the boilerplate files
// change if you have an htdocs dir or similar
// maxAge is set to one month
connect.static(__dirname, {maxAge: oneMonth})
);
// bind the server to a port, choose your port:
server.listen(80); // 80 is the default web port and 443 for TLS
// Your server is running :-)
console.log('Node server is running!');
var connect = require("connect");
connect(
connect.static(__dirname + "/public"),
// create a router to handle application paths
connect.router(function(app) {
app.get("/sayHello/:firstName/:lastName", function(req, res) {
var userName = req.params.firstName + " " + req.params.lastName,
html = "" +
"<title>Hello " + userName + "</title>" +
"<h1>Hello, " + userName + "!</h1>";
res.end(html);
});
})
).listen(8000);
browser: function () {
console.log('starting browser-based tests')
var connect = require('connect'),
html = fs.readFileSync(__dirname + "/suite.html", "utf-8"),
doc,
modules,
specs,
app = connect(
connect.static(_path.join(__dirname, '..', 'tasks', 'vendor')),
connect.static(__dirname),
connect.router(function (app) {
app.get('/cordova.test.js', function (req, res) {
res.writeHead(200, {
"Cache-Control": "no-cache",
"Content-Type": "text/javascript"
});
res.end(bundle('test'));
}),
app.get('/', function (req, res) {
res.writeHead(200, {
"Cache-Control": "no-cache",
"Content-Type": "text/html"
});
//create the script tags to include
tests = [];
collect(__dirname, tests);
function echoServer() {
var port = exports.port;
//exports.port += 1;
var server = Connect.createServer(
Connect.bodyParser(),
Connect.router(function (app) {
app.post('/', handler);
})
);
function handler(request, response, next) {
var payload = _getRequestJSON(request);
var headers = {
'content-type': 'application/json',
'x-test1': 'ASDF1',
'x-test2': 'ASDF2'
};
response.writeHead(200, headers);
if (request.method !== 'HEAD') {
exports.main = function(options) {
var server = CONNECT();
server.use(CONNECT.router(function(app) {
app.get(/^\/loader.js/, CONNECT.static(PATH.dirname(require.resolve("sourcemint-loader-js/loader.js"))));
app.get(/^(?:\/demo\/kitchen-sink)(?:\.js)?(\/.*)?$/, BUNDLER.hoist(PATH.dirname(__dirname) + "/demo/kitchen-sink", {
distributionBasePath: __dirname + "/dist",
packageIdHashSeed: "__ACE__",
bundleLoader: false,
logger: {
log: function() {
console.log.apply(null, arguments);
}
}
}));
app.get(/^\//, function(req, res)
{
that.setupRoutes = function(server) {
server.use('/', connect.router(function routes(app) {
app.get('/auth/sina_callback', function(req, res) {
req.authenticate([that.name], function(error, authenticated) {
res.writeHead(303, { 'Location': req.session.sina_redirect_url });
res.end('');
});
});
}));
};
exports.main = function()
{
var server = CONNECT();
server.use(CONNECT.router(function(app)
{
app.get(/^\/$/, function(req, res)
{
res.writeHead(302, {
"Location": "http://127.0.0.1:" + PORT + "/workspace/www/"
});
res.end();
});
app.get(/^\/loader.js$/, function(req, res)
{
res.setHeader("Content-Type", "text/javascript");
res.end(getRawSource());
});
app.get(/^\/loader.stripped.js$/, function(req, res)
{
res.setHeader("Content-Type", "text/plain");
that.setupRoutes= function(server) {
server.use('/', connect.router(function routes(app){
app.get('/auth/foursquare_callback', function(req, res){
req.authenticate([that.name], function(error, authenticated) {
res.writeHead(303, { 'Location': req.session.foursquare_redirect_url });
res.end('');
});
});
}));
}
mu.render('multi.html.mu', { tests: tests, js: js }).pipe(res);
});
};
if (process.env.PORT) {
connect.createServer(
connect.router(router),
connect.staticCache(),
connect.static(__dirname + '/public'),
connect.favicon(__dirname + '/public/images/favicon.ico')
).listen(process.env.PORT);
} else {
connect.createServer(
connect.logger('dev'),
connect.router(router),
connect.static(__dirname + '/public')
).listen(3000)
}
exports.createServer = function(routes) {
var app;
var server = connect()
.use(connect.router(function(app_) {
app = app_;
}));
server.addRoute = function(method, route, handler) {
method = method.toLowerCase() || "get";
app[method](route, handler);
};
return server;
};