Quellcode durchsuchen

feat: add cookie parser

develop
Dale vor 3 Monaten
Ursprung
Commit
54e737a21c
Signiert von: Deiru GPG-Schlüssel-ID: AA250C0277B927E1
4 geänderte Dateien mit 54 neuen und 17 gelöschten Zeilen
  1. +2
    -0
      package.json
  2. +2
    -0
      restart-server.sh
  3. +20
    -17
      src/server.ts
  4. +30
    -0
      yarn.lock

+ 2
- 0
package.json Datei anzeigen

@@ -17,6 +17,7 @@
"async-shelljs": "^0.1.2",
"axios": "^0.19.0",
"classnames": "^2.2.6",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"ejs": "^2.6.1",
"emotion": "^10.0.27",
@@ -31,6 +32,7 @@
},
"devDependencies": {
"@types/classnames": "^2.2.10",
"@types/cookie-parser": "^1.4.2",
"@types/ejs": "^2.6.3",
"@types/express": "^4.16.1",
"@types/gamedig": "^1.0.0",


+ 2
- 0
restart-server.sh Datei anzeigen

@@ -4,6 +4,8 @@
git pull
# Build server
NODE_ENV=production yarn build:server
# Update deps
yarn
# Kill previous instance
screen -S gensoc-status -X quit
# Start a new one


+ 20
- 17
src/server.ts Datei anzeigen

@@ -1,31 +1,34 @@
import Express from 'express';
import cors = require('cors');
import Express from "express";
import cookieParser from "cookie-parser";
import cors = require("cors");


import {serveDomains} from 'src/lib/domains';
import statusRouter from 'src/domains/status';
import landingRouter from 'src/domains/landing';
import { serveDomains } from "src/lib/domains";
import statusRouter from "src/domains/status";
import landingRouter from "src/domains/landing";

const app = Express();

const STATIC_PATH = process.env.STATIC_PATH || './static';
const STATIC_PATH = process.env.STATIC_PATH || "./static";
const PORT = process.env.PORT || 8080;

const developing = process.env.NODE_ENV === 'development';
const developing = process.env.NODE_ENV === "development";

const domains = developing ? {
'gensokyo-status.local': statusRouter,
'gensokyo-landing.local': landingRouter,
} : {
'status.gensokyo.social': statusRouter,
'gensokyo.social': landingRouter,
};
const domains = developing
? {
"gensokyo-status.local": statusRouter,
"gensokyo-landing.local": landingRouter,
}
: {
"status.gensokyo.social": statusRouter,
"gensokyo.social": landingRouter,
};

const dispatcher = serveDomains(domains);

app.use('/static', cors(), Express.static(STATIC_PATH));
app.use(cookieParser() as any);
app.use("/static", cors(), Express.static(STATIC_PATH));
app.use(dispatcher);

app.listen(PORT, () => {
console.log(`listening on ${PORT}`)
console.log(`listening on ${PORT}`);
});

+ 30
- 0
yarn.lock Datei anzeigen

@@ -152,6 +152,13 @@
dependencies:
"@types/node" "*"

"@types/cookie-parser@^1.4.2":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@types/cookie-parser/-/cookie-parser-1.4.2.tgz#e4d5c5ffda82b80672a88a4281aaceefb1bd9df5"
integrity sha512-uwcY8m6SDQqciHsqcKDGbo10GdasYsPCYkH3hVegj9qAah6pX5HivOnOuI3WYmyQMnOATV39zv/Ybs0bC/6iVg==
dependencies:
"@types/express" "*"

"@types/cookiejar@*":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.1.tgz#90b68446364baf9efd8e8349bb36bd3852b75b80"
@@ -175,6 +182,16 @@
"@types/node" "*"
"@types/range-parser" "*"

"@types/express@*":
version "4.17.9"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.9.tgz#f5f2df6add703ff28428add52bdec8a1091b0a78"
integrity sha512-SDzEIZInC4sivGIFY4Sz1GG6J9UObPwCInYJjko2jzOf/Imx/dlpume6Xxwj1ORL82tBbmN4cPDIDkLbWHk9hw==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "*"
"@types/qs" "*"
"@types/serve-static" "*"

"@types/express@^4.16.1":
version "4.16.1"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.16.1.tgz#d756bd1a85c34d87eaf44c888bad27ba8a4b7cf0"
@@ -233,6 +250,11 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==

"@types/qs@*":
version "6.9.5"
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.5.tgz#434711bdd49eb5ee69d90c1d67c354a9a8ecb18b"
integrity sha512-/JHkVHtx/REVG0VVToGRGH2+23hsYLHdyG+GrvoUGlGAd0ErauXDyvHtRI/7H7mzLm+tBCKA7pfcpkQ1lf58iQ==

"@types/ramda@^0.26.9":
version "0.26.9"
resolved "https://registry.yarnpkg.com/@types/ramda/-/ramda-0.26.9.tgz#f0bbba59c04de9d29aaa1d1c0daedefc7244bb68"
@@ -1403,6 +1425,14 @@ convert-source-map@^1.5.0:
dependencies:
safe-buffer "~5.1.1"

cookie-parser@^1.4.5:
version "1.4.5"
resolved "https://registry.yarnpkg.com/cookie-parser/-/cookie-parser-1.4.5.tgz#3e572d4b7c0c80f9c61daf604e4336831b5d1d49"
integrity sha512-f13bPUj/gG/5mDr+xLmSxxDsB9DQiTIfhJS/sqjrmfAWiAN+x2O4i/XguTL9yDZ+/IFDanJ+5x7hC4CXT9Tdzw==
dependencies:
cookie "0.4.0"
cookie-signature "1.0.6"

cookie-signature@1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"


Laden…
Abbrechen
Speichern