forked from AdobeDocs/adobe-dev-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.mjs
More file actions
28 lines (22 loc) · 738 Bytes
/
dev.mjs
File metadata and controls
28 lines (22 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// content/docs
// serve static on 3001
import express from 'express';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const PORT = process.env.DEV_PORT || 3003;
// TODO: ensure `DOCS_DIRECTORY` starts with `/`
const DOCS_DIRECTORY = process.env.DIRECTORY || './src/pages';
const app = express();
console.log(path.resolve(__dirname, `./${DOCS_DIRECTORY}`));
app.use(
express.static(path.resolve(__dirname, `./${DOCS_DIRECTORY}`), {
setHeaders: (res) => {
res.setHeader('last-modified', new Date().toGMTString());
},
}),
);
app.listen(PORT, () => {
console.debug(`Docs dev server is running on port ${PORT}`);
});