當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。