kopia lustrzana https://github.com/badgen/badgen.net
Arrange assets folder
rodzic
8b14255ac0
commit
7144e5e542
10
index.ts
10
index.ts
|
@ -12,20 +12,22 @@ const sendError = (req, res, error) => {
|
|||
}
|
||||
|
||||
const badgeHandlers = fs.readdirSync(path.join(__dirname, 'endpoints'))
|
||||
.filter(name => !name.startsWith('_'))
|
||||
.map(name => name.replace(/\.ts$/, ''))
|
||||
.filter(name => /\.[jt]s$/.test(name))
|
||||
.map(name => name.replace(/\.[jt]s$/, ''))
|
||||
|
||||
const isStatic = (url) => {
|
||||
if (url === '/') return true
|
||||
if (url.startsWith('/static/')) return true
|
||||
if (url.startsWith('/_next/')) return true
|
||||
if (url.startsWith('/static/')) return true
|
||||
if (url.startsWith('/builder')) return true
|
||||
return false
|
||||
}
|
||||
|
||||
const { PUB_DIR = '.' } = process.env
|
||||
const server = http.createServer(async (req, res) => {
|
||||
// handle statics
|
||||
if (isStatic(req.url)) {
|
||||
return serveHandler(req, res, { public: path.join(__dirname, 'dist') })
|
||||
return serveHandler(req, res, { public: path.resolve(__dirname, PUB_DIR) })
|
||||
}
|
||||
|
||||
// handle `/docs/:name`
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
module.exports = {
|
||||
target: 'serverless'
|
||||
target: 'serverless',
|
||||
exportPathMap: async function (defaultPathMap) {
|
||||
return {
|
||||
'/': { page: '/index' },
|
||||
'/builder': { page: '/builder' }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"predev": "npm run now-build",
|
||||
"dev": "nodemon -e ts,js -w endpoints -w libs -x 'ts-node index.ts'",
|
||||
"build": "npm run tools && next build && next export -o dist && tsc",
|
||||
"predev": "npm run build",
|
||||
"dev": "PUB_DIR=dist nodemon -e ts,js -w endpoints -w libs -x 'ts-node index.ts'",
|
||||
"dev:web": "next",
|
||||
"tools": "ts-node tools/gen-examples.ts",
|
||||
"now-build": "npm run tools && next build && next export -o dist",
|
||||
"now-build": "npm run build",
|
||||
"pretest": "npm run lint",
|
||||
"test": "tap test/*.js --reporter spec -j12",
|
||||
"start": "node service.js",
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "dist-server",
|
||||
"outDir": "dist",
|
||||
"baseUrl": ".",
|
||||
"lib": ["dom", "esnext"]
|
||||
},
|
||||
|
|
Ładowanie…
Reference in New Issue