当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript cookie-parser.default方法代码示例

本文整理汇总了TypeScript中cookie-parser.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript cookie-parser.default方法的具体用法?TypeScript cookie-parser.default怎么用?TypeScript cookie-parser.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cookie-parser的用法示例。


在下文中一共展示了cookie-parser.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: start

export default function start(serverDataPath: string) {
  dataPath = serverDataPath;
  SupCore.log(`Using data from ${dataPath}.`);
  process.on("uncaughtException", onUncaughtException);

  loadConfig();

  const { version, superpowers: { appApiVersion: appApiVersion } } = JSON.parse(fs.readFileSync(`${__dirname}/../package.json`, { encoding: "utf8" }));
  SupCore.log(`Server v${version} starting...`);
  fs.writeFileSync(`${__dirname}/../public/superpowers.json`, JSON.stringify({ version, appApiVersion, hasPassword: config.server.password.length !== 0 }, null, 2));

  // SupCore
  (global as any).SupCore = SupCore;
  SupCore.systemsPath = path.join(dataPath, "systems");

  // List available languages
  languageIds = fs.readdirSync(`${__dirname}/../public/locales`);
  languageIds.unshift("none");

  // Main HTTP server
  mainApp = express();

  mainApp.use(cookieParser());
  mainApp.use(handleLanguage);

  mainApp.get("/", (req, res) => { res.redirect("/hub"); });
  mainApp.get("/login", serveLoginIndex);
  mainApp.get("/hub", enforceAuth, serveHubIndex);
  mainApp.get("/project", enforceAuth, serveProjectIndex);

  mainApp.use("/projects/:projectId/*", serveProjectWildcard);
  mainApp.use("/", express.static(`${__dirname}/../public`));

  mainHttpServer = http.createServer(mainApp);
  mainHttpServer.on("error", onHttpServerError.bind(null, config.server.mainPort));

  io = socketio(mainHttpServer, { transports: [ "websocket" ] });

  // Build HTTP server
  buildApp = express();

  buildApp.get("/", redirectToHub);
  buildApp.get("/systems/:systemId/SupCore.js", serveSystemSupCore);

  buildApp.use("/", express.static(`${__dirname}/../public`));

  buildApp.get("/builds/:projectId/:buildId/*", (req, res) => {
    const projectServer = hub.serversById[req.params.projectId];
    if (projectServer == null) { res.status(404).end("No such project"); return; }
    let buildId = req.params.buildId as string;
    if (buildId === "latest") buildId = (projectServer.nextBuildId - 1).toString();
    res.sendFile(path.join(projectServer.buildsPath, buildId, req.params[0]));
  });

  buildHttpServer = http.createServer(buildApp);
  buildHttpServer.on("error", onHttpServerError.bind(null, config.server.buildPort));

  loadSystems(mainApp, buildApp, onSystemsLoaded);

  // Save on exit and handle crashes
  process.on("SIGINT", onExit);
  process.on("message", (msg: string) => { if (msg === "stop") onExit(); });
}
开发者ID:alphafork,项目名称:Game-Engine-superpowers-core,代码行数:63,代码来源:start.ts

示例2: configureApp

    configureApp() {
        let host = nconf.get("HostInfo");
        let corsOptions = {
            origin: host.SPAUrl,
            methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
            credentials: true,
            preflightContinue: false
        };

        // uncomment after placing your favicon in /public
        this.app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
        this.app.use(cors(corsOptions));
        this.app.use(logger('dev'));
        this.app.use(bodyParser.json());
        this.app.use(bodyParser.urlencoded({ extended: false }));
        this.app.use(cookieParser());
        this.app.use(session({ secret: 'hakans planner hackathon', resave: false, saveUninitialized: false }));
        this.app.use(express.static(path.join(__dirname, 'public')));

        // setup view engine
        this.app.set('views', path.join(__dirname, 'views'));
        this.app.set('view engine', 'jade');
    }
开发者ID:hakant,项目名称:HackathonPlannerAPI,代码行数:23,代码来源:app.ts

示例3: bootstrap

async function bootstrap() {
    const app = await NestFactory.create(AppModule);

    app.use(
        session({
            secret: 'No sera de tomar un tragito',
            sesave: false,
            saveUninitialixed: true,
            cookie: {
                secure:false
            },
            name:'server-session-id',
            store: new FileStore()
        })
    );

    app.use(cookieParser(
        'me gustan los tacos', // secreto
        {  // opciones

        }
    ));
    app.set('view engine', 'ejs');

    app.use(
      express.static('publico')
    );

    // /public/texto.txt
    // localhost:3000/texto.txt

    // /public/ejemplo/texto.txt
    // localhost:3000/ejemplo/texto.txt

    await app.listen(3000);

}
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:caiza-llumitaxi-jonathan-paul,代码行数:37,代码来源:main.ts

示例4: bootstrap

async function bootstrap() {
    const app = await NestFactory.create(AppModule);

    app.use(
        session ({
        secret:'No sera de tomar un traguito',
        resave: false,
        saveUninitialized: true,
        cookie: {secure: false},
        name:'server-session-id',
        store: new FileStore()
    })
);

    app.use(cookieParser(
        'me gustan los tacos', // secreto
        {  // opciones

        }
    ));
    app.set('view engine', 'ejs');

    await app.listen(3000);
}
开发者ID:2018-B-GR1-AplicacionesWeb,项目名称:Beltran-Venegas-Daniel-Alexander,代码行数:24,代码来源:main.ts

示例5: constructor

    constructor() {
        this.app = loopback();

        this.app.use(cookieParser());

        this.app.start = async () => {
            // start the web server
            const models = this.app.models();
            const model = models[0] as (typeof loopback.PersistedModel);

            const data = await model.findOne<TestModel>();

            if (data) {
                console.dir(data.name);
            }

            model.findOne<TestModel>({}, (err, instance) => {
                if (err) {
                    console.dir(err);
                }
                console.dir(instance.name);
            });
        };
    }
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:24,代码来源:loopback-tests.ts

示例6: express

      'DELETE /bulk': {
        type: ActionType.Destroy,
        byId: false,
        byList: true,
        authorization: {permission: Permissions.UserCreate},
      },
    },
  },
  '/v1/posts': {
    modelName: ModelId.Post,
    routes: {
      'GET /': {type: ActionType.List},
      'POST /search': {type: ActionType.List, expectQueryIn: ValidateIn.Body},

      'POST /': {type: ActionType.Create},
      'GET /:id': {type: ActionType.Read},
      'PUT /:id': {type: ActionType.Update},
      'DELETE /:id': {type: ActionType.Destroy},
    },
  },
}

export const app: express.Express = express()
if (typeof (global as any).it === 'undefined') app.use(logger('short'))
app.use(json({strict: false}))
app.use(cookies())
app.use(authenticate(authConf))
app.use(createAndMergeRouters(kiln, routerMap).router)
app.use(createHandlePromiseMiddleware())
app.use(createHandleErrorMiddleware())
开发者ID:patrickhulce,项目名称:klay,代码行数:30,代码来源:app.ts

示例7: express

import { enableProdMode } from '@angular/core';
// Angular 2 Universal
import { expressEngine } from 'angular2-universal';

// enable prod for faster renders
enableProdMode();

const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));

// Express View
app.engine('.html', expressEngine);
app.set('views', __dirname);
app.set('view engine', 'html');

app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json());

// Serve static files
app.use('/assets', express.static(path.join(__dirname, 'assets'), {maxAge: 30}));
app.use(express.static(path.join(ROOT, 'dist/client'), {index: false}));


import { getOptions, castVote } from './backend/api';
// Our API for demos only
app.get('/data/options', getOptions);
app.post('/data/options/vote/:beerId', castVote)

import { ngApp } from './main.node';
// Routes with html5pushstate
// ensure routes match client-side-app
开发者ID:dandybateman,项目名称:PourcastVoter,代码行数:31,代码来源:server.ts

示例8: Date

    var str: string = "\r\n" + new Date().toLocaleString() + "\r\n";
    str += JSON.stringify(err);

    fs.appendFile(SERVER + '/error.log', str);
};

//////////   Types  only/////////////
import {Request} from "express";
import {Response} from "express";
import {Express} from "express";
///////////////////////////////////////

const app:Express = express();

// configure our app to use bodyParser(it let us get the json data from a POST)
app.use(cookie());
app.use(session({
    resave: false, // don't save session if unmodified
    saveUninitialized: false, // don't create session until something stored
    secret:'somesecrettokenhere'
}));


app.use('/api',bodyParser.urlencoded({extended: true}));
app.use('/api',bodyParser.json());

app.use(express.static(WWW));

app.get('/', function(req:express.Request, res:express.Response){
    res.sendFile('indexts.html',{ 'root':WWW});
});
开发者ID:shumik-vladyslav,项目名称:DigitalSignagePlayList,代码行数:31,代码来源:server.ts

示例9: express

import {DbConnection} from "./database";
import {credentials} from "./secret";
import * as bodyParser from "body-parser";
import {UserController} from "./controllers/userController";
import {LoanController} from "./controllers/loanController";
import {BookCopyController} from "./controllers/bookCopyController";

let app = express();
let api = express();
app.use("/api", api);

app.use(require("morgan")("dev"));
DbConnection.initConnection(app.get("env"));

app.set("port", process.env.PORT || 5000);
app.use(cookieParser(credentials.cookieSecret));
app.use(expressSession());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

//TODO.md: domains are deprecated and will be removed in the future,
//find an alternative
app.use(function (req, res, next) {
    console.log("heeyy it works!");
    var domain = require("domain").create();

    domain.on("error", function (err) {
        console.error("Domain error caught! \n", err.stack);
        try {
            setTimeout(function () {
                console.error("Failsafe shutdown");
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:31,代码来源:server.ts

示例10: express

////////////////////////////////////

process.on('uncaughtException', (err: Error) => {
	console.error(err)
	process.exit(1)
})
process.on('unhandledRejection', (reason: string, p: Promise<any>) => {
	console.error('Unhandled Rejection at: Promise', p, 'reason:', reason)
	process.exit(1)
})

////////////

var app = express()
app.use(cookie_parser())

////////////

app.get('/', (req, res) => {
	res.sendFile('index.html', { root: __dirname })
})
app.get('/client.js', (req, res) => {
	res.sendFile('client.js', { root: __dirname + '/..' })
})

app.get('/best-locales', best_locales_middleware)

app.get('/set-locale', (req, res) => {
	const locale: BCP47Locale | undefined = normalize_and_validate_bcp47_locale(req.query.lang)
开发者ID:Offirmo,项目名称:web-tech-experiments,代码行数:29,代码来源:express_server.ts


注:本文中的cookie-parser.default方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。