mapillary-js/server.js
Oscar Lorentzon b562a0b06c chore: build with rollup
Migrate to Rollup.
Emit umd, minified umd, module, type declarations
and source maps.
Work around problems with Falcor by using
virtual module.

Migrate to Jest.
Run tests in with CommonJS modules becasue ES6
is not supported.
Work around dependency problems by bootstrap
to ensure they are not loaded during test.

Remove all unused dependencies.

Create state transition matrix to avoid
circular dependencies.

chore: tsc and rollup watch build
chore: incremental watch build
Remove unused dependencies.
chore: use existing type packages
chore: mock favicon
chore: improve watch build
chore: fix styles build
chore: specific commonjs build for tests
chore: reset spec files
refactor: explicit state transition matrix
chore: make src commands work
chore: working unit tests and lib
chore: add serve docs script
chore: remove unused bundle config
chore: refactor rollup config to avoid duplication
fix: falcor imports
fix: transition from source to target

Fixes #87
Fixes #100
Fixes #159
Fixes #208
2021-03-15 11:23:22 +01:00

38 lines
993 B
JavaScript

'use strict';
import express from 'express';
import { join } from 'path';
const PORT = 8000;
const pathname = dirname => {
const path = join(import.meta.url, `../${dirname}`);
return new URL(path).pathname;
}
const logger = (req, res, next) => {
const clearColor = '\x1b[0m';
res.on('finish', () => {
const color = res.statusCode === 200 ?
clearColor : '\x1b[31m';
const format = `${color}%s${clearColor}`;
const message = `[${new Date().toISOString()}] ${req.method} ` +
`${req.path} ${res.statusCode}`;
console.log(format, message);
});
next();
};
const app = express();
app.use(logger);
app.use('/', express.static(pathname('debug')));
app.use('/dist', express.static(pathname('dist')));
app.get('/debug', (_, res) => { res.redirect('/'); });
app.listen(PORT, () => {
const message =
`mapillary-js debug server running at ` +
`http://localhost:${PORT}`;
console.log(message);
});