Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Lang = require("tnw").Lang;
const SubscribeMsgApi = require("tnw").SubscribeMsgApi;
const SubscribeMsg = require("tnw").SubscribeMsg;
const Data = require("tnw").Data;
const Content = require("tnw").Content;
const MsgController = require('./MsgController').MsgController;
const MenuManager = require('./MenuManager').MenuManager;
const express = require('express');
const fs = require('fs');
const app = express();
// 被动消息回复控制器
const msgAdapter = new MsgController();
app.use(express.static('views'));
app.get('/', (req, res) => {
res.send("TNW 极速开发微信公众号案例 <a href="https://javen.blog.csdn.net">By Javen</a> <br> " +
"此案例使用的技术栈为: TypeScript+ Node.js + Express <br><br>" +
"交流群:<a href="https://github.com/Javen205/shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24">114196246</a><br><br>" +
"开源推荐:<br>" +
"1、IJPay 让支付触手可及(聚合支付SDK):<a href="\"https://gitee.com/javen205/IJPay\"">https://gitee.com/javen205/IJPay</a><br>" +
"2、SpringBoot 微服务高效开发 mica 工具集:<a href="\"https://gitee.com/596392912/mica\"">https://gitee.com/596392912/mica</a><br>" +
"3、pig 宇宙最强微服务(架构师必备):<a href="\"https://gitee.com/log4j/pig\"">https://gitee.com/log4j/pig</a><br>" +
"4、SpringBlade 完整的线上解决方案(企业开发必备):<a href="\"https://gitee.com/smallc/SpringBlade\"">https://gitee.com/smallc/SpringBlade</a><br>" +
"5、Avue 一款基于 vue 可配置化的神奇框架:<a href="\"https://gitee.com/smallweigit/avue\"">https://gitee.com/smallweigit/avue</a> ");
});
/**
* 验证开发者入口
function setup_routes(app) {
// static paths
app.use(express.static(paths.webserver_root)); // all files in this directory are served to bela.local/
app.use('/documentation', express.static(paths.Bela + 'Documentation/html'));
// ajax routes
// file and project downloads
app.get('/download', routes.download);
// doxygen xml
app.get('/documentation_xml', routes.doxygen);
// hack for workship script
app.get('/rebuild-project', routes.rebuild_project);
}
function get_xenomai_version() {
// **************************************
//
// app.js
// This file contains the server side JavaScript code for the Event Detection sample application.
// This starter application uses express as its web application framework and jade as its template engine.
var https = require('https');
var express = require('express');
var async = require('async');
var fs = require('fs');
var FormData = require('form-data');
var errorhandler = require('errorhandler');
// Setup middleware
var app = express();
app.use(errorhandler());
app.use(express.static(__dirname + '/public')); //setup static public directory
app.set('view engine', 'jade');
app.set('views', __dirname + '/views'); //optional since express defaults to CWD/views
app.use(require('body-parser').json());
// Array used to reflect status of the 6 majors steps of this app on its web UI.
var status_step = ["Pending", "Pending", "Pending", "Pending", "Pending", "Pending"];
// Render index page of the app's single page web UI
app.get('/', function(req, res){
res.render('index', {'events':events, 'maxmin':maxmin, 'status':status_step, 'eventTarget':eventTarget});
});
// POST handler for the events being sent back from the Streams application
app.post('/', function(req, res){
status_step[4] = "Processing Events";
app.jsl.perm = require('./core/permissions');
//sessions
app.jsl.sess = require('./core/sessions');
//pagination
app.jsl.pag = require('./core/pagination');
//utils
app.jsl.utils = require('./core/utils');
app.jsl.utils.app = app; //mi serve che utils conosca internamente app
//routes
app.jsl.routes = require('./core/routes');
//init router
app.use(app.router);
//declare public dir
app.use(express.static(__dirname + '/public'));
// Routes
//nota: le route sono importate, prima quelle di jslardo, poi quelle per ciascuno degli oggetti persistenti nel db
//route miscellanee di jslardo
app.jsl.routes.defineRoutes(app);
//route per gli elementi della struttura
require('./controllers/user').defineRoutes(app);
require('./controllers/role').defineRoutes(app);
//require('./controllers/module').defineRoutes(app);
require('./controllers/debuggin').defineRoutes(app);
//per questi elementi oltre alle route, mi servono anche altri metodi esposti dal controller, quindi devo tenere tutto il controller
app.jsl.pageController = require('./controllers/page');
app.jsl.pageController.defineRoutes(app);
app.jsl.siteController = require('./controllers/site');
app.set('api_secret_key', config.api_secret_key);
// Middleware
const verifyToken = require('./middleware/verify-token');
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', index);
app.use('/api', verifyToken);
app.use('/api/movies', movie);
app.use('/api/directors', director);
// catch 404 and forward to error handler
app.use((req, res, next) => {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use((err, req, res, next) => {
// set locals, only providing error in development
app.configure(function() {
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(app.router);
app.use(express.cookieParser());
app.set('view engine', 'ejs');
app.set('view options', { layout: false });
// Set directories
app.use(express['static']('bower_components'));
app.use(express['static']('lib'));
app.use(express['static']('examples'));
app.use(express['static']('test'));
app.use('/dist', express['static']('dist'));
app.set('views', __dirname);
});
app.use(rootPath + '/js/node_modules', express.static(resolveRelativePath('../../node_modules', __dirname)));
app.use(rootPath + '/js/common', express.static(resolveRelativePath('../common', __dirname)));
app.use(rootPath + '/js/client', express.static(resolveRelativePath('../client', __dirname)));
app.use(rootPath + '/js', express.static(resolveRelativePath('clientjs', __dirname)));
app.use(rootPath + '/static', express.static(resolveRelativePath('../static', __dirname)));
app.use(rootPath + '/static', express.directory(resolveRelativePath('../static', __dirname), {icons:true}));
app.use(rootPath + '/output', express.static(config.outputPath));
app.use(rootPath + '/output', express.directory(config.outputPath, {icons:true}));
app.use(rootPath + '/css', express.static(resolveRelativePath('css', __dirname)));
// These are the MATHia fluency tasks. On the production server, these are served directly by nginx instead of going through the node webapp. We have these static handlers so dev environment can run without the nginx reverse proxy.
app.use(rootPath + '/fluency/data', express.static(config.dataPath));
app.use(rootPath + '/fluency/data', express.directory(config.dataPath, {icons:true}));
// Cache Flash resources for 10 seconds.
app.use(rootPath + '/fluency/games', express.static(config.cliFlashPath, {maxAge: 10000}));
app.use(rootPath + '/fluency/games', express.directory(config.cliFlashPath, {icons:true}));
// Middleware to load student or instructor data before processing requests.
app.use(function (req, res, next)
{
if (req.session && req.session.instructorID)
{
model.Instructor.find(req.session.instructorID).on('success', function (instructor)
{
req.instructor = instructor;
next();
});
}
else if (req.session && req.session.studentID)
{
import express from 'express';
import React from 'react';
import { renderToString } from 'react-dom/server';
import App from './App';
import template from './template';
const server = express();
server.use('/dist', express.static('dist'));
server.get('/', (req, res) => {
const app = ;
const appString = renderToString(app);
res.send(
template({
body: appString,
}),
);
});
server.listen(8080);
console.log('server ready');
private addStaticHandler(): void {
this._app.use(express.static(__dirname + "/../public"));
this._app.use((_, res) => {
res.status(404);
res.type("txt").send("Not found");
});
}
function doConf() {
app.use(express.favicon());
app.use(express.logger(config.HEARTHSTONE_ENV));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({
secret: config.session_secret
}));
app.use(userHandler.authenticate);
app.use(app.router);
app.use(express.static(path.join(application_root, config.HEARTHSTONE_PUBLIC_FOLDER)));
app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
}