Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Commit

Permalink
feat!: switch to stub server
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbuehner committed Apr 7, 2024
1 parent 560c727 commit 15b8e32
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
3 changes: 2 additions & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"inspect-prod": "npm run dev:prepare && tsc --build && cross-env PORT=${PORT:=3000} NODE_OPTIONS=${SERVER_NODE_OPTIONS} APP_URL=${APP_URL:=https://cristata.app} AUTH_APP_URL=${AUTH_APP_URL:=https://auth.cristata.app} NODE_ENV=development node --inspect dist/index.js",
"build": "tsc --build && tsc --declaration && cross-env NODE_ENV=production npm run lint",
"check": "tsc && npm run lint",
"test": "jest",
"test": "",
"test.old": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"clean": "rm -rf dist",
"postinstall": "patch-package --error-on-fail false",
Expand Down
10 changes: 10 additions & 0 deletions apps/server/src/index.old.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import CristataServer from './Cristata';

const server = new CristataServer();
server.start();

// log the stack of warnings so we can figure out from where the warning is coming
process.on('warning', (error) => {
console.warn(error);
console.warn(error.stack);
});
30 changes: 20 additions & 10 deletions apps/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import CristataServer from './Cristata';

const server = new CristataServer();
server.start();

// log the stack of warnings so we can figure out from where the warning is coming
process.on('warning', (error) => {
console.warn(error);
console.warn(error.stack);
});
import cors from 'cors';
import express from 'express';

if (!process.env.PORT) throw new Error('PORT not defined in env');

// create express app
const app = express();

// enable CORS for the app
app.use(cors({ origin: true }));

// always redirect troop-370 file urls since they no longer use Cristata
// but they want the old filestore urls to still work
app.get('/filestore/troop-370/:_id', (req, res) => {
res.redirect(301, `https://troop370atlanta.org/cristata-filestore/${req.params._id}`);
});

app.listen(process.env.PORT, () => {
console.log(`Cristata server stub listening on port ${process.env.PORT}!`);
});

0 comments on commit 15b8e32

Please sign in to comment.