Prepared for Garden
This commit is contained in:
parent
4900169860
commit
b3f9845f2a
12 changed files with 28 additions and 63 deletions
|
@ -1 +1,2 @@
|
||||||
src/uploads/
|
src/uploads/
|
||||||
|
uploads/
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -9,3 +9,5 @@ src/uploads/
|
||||||
.env
|
.env
|
||||||
.env.dev
|
.env.dev
|
||||||
.env.prod
|
.env.prod
|
||||||
|
newsrc/
|
||||||
|
uploads/
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
FROM node:latest
|
FROM node:16
|
||||||
RUN apt-get update && apt-get upgrade -y
|
WORKDIR /dunemask/net/nubian
|
||||||
WORKDIR /dunestorm/nubian
|
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
RUN npm i --only=prod
|
RUN npm i
|
||||||
COPY src src
|
COPY src src
|
||||||
CMD ["npm","start"]
|
CMD ["npm","start"]
|
||||||
EXPOSE 52001
|
|
||||||
|
|
14
dist/predeploy-vanilla.sh
vendored
14
dist/predeploy-vanilla.sh
vendored
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
echo "Creating vanilla predeploy!"
|
|
||||||
# Set path correclty
|
|
||||||
if [[ $PWD == *"dist" ]];
|
|
||||||
then cd ..
|
|
||||||
fi
|
|
||||||
# If .env exists, ignore it
|
|
||||||
if [[ ! -f ".env" ]];then
|
|
||||||
echo "Building vanilla env file!"
|
|
||||||
echo "KHUFU_UPLOAD_PATH=/srv/uploads">> .env
|
|
||||||
fi
|
|
||||||
# Install node dependencies
|
|
||||||
echo "Installing node depencencies!"
|
|
||||||
npm i
|
|
|
@ -1,18 +0,0 @@
|
||||||
version: "3"
|
|
||||||
services:
|
|
||||||
nubian.dunestorm.net:
|
|
||||||
image: nubian.dunestorm.net
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- "52001:52001"
|
|
||||||
environment:
|
|
||||||
- ALEXANDRIA_INTERNAL_URL=${ALEXANDRIA_INTERNAL_URL}
|
|
||||||
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
|
|
||||||
- CAIRO_PUBLIC_URL=${CAIRO_PUBLIC_URL}
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
networks:
|
|
||||||
- dunestorm_dev
|
|
||||||
networks:
|
|
||||||
dunestorm_dev:
|
|
||||||
external: true
|
|
26
package.json
26
package.json
|
@ -5,9 +5,7 @@
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node src/index.js --no-warnings",
|
"start": "node src/index.js --no-warnings",
|
||||||
"start:dev": "nodemon src/index.js",
|
"start:dev": "nodemon src/index.js"
|
||||||
"build": "npm run build:all",
|
|
||||||
"build:all": "docker-compose build"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -22,26 +20,20 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
"chalk": "^4.1.2",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-bearer-token": "^2.4.0",
|
"express-bearer-token": "^2.4.0",
|
||||||
|
"figlet": "^1.5.2",
|
||||||
|
"moment": "^2.29.1",
|
||||||
"mongoose": "^5.13.3",
|
"mongoose": "^5.13.3",
|
||||||
"multer": "^1.4.2",
|
"multer": "^1.4.2",
|
||||||
|
"multer-gridfs-storage": "^5.0.2",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
"pg-promise": "^10.11.1",
|
||||||
|
"postgres-migrations": "^5.3.0",
|
||||||
"rimraf": "^3.0.2"
|
"rimraf": "^3.0.2"
|
||||||
},
|
},
|
||||||
"nodemonConfig": {
|
"devDependencies": {
|
||||||
"restartable": "rs",
|
"nodemon": "^2.0.14"
|
||||||
"ignore": [
|
|
||||||
".git",
|
|
||||||
"./src/uploads/",
|
|
||||||
"./src/zips/"
|
|
||||||
],
|
|
||||||
"verbose": true,
|
|
||||||
"ext": "js,json",
|
|
||||||
"signal": "SIGINT",
|
|
||||||
"env": {
|
|
||||||
"CAIRO_URL": "http://localhost:52000",
|
|
||||||
"KHUFU_UPLOAD_PATH": "uploads/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@ const {
|
||||||
const config = require("../config.json");
|
const config = require("../config.json");
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
mongoose.connect(
|
mongoose.connect(
|
||||||
`mongodb://${process.env.ALEXANDRIA_INTERNAL_URL}/nubian?authSource=admin`,
|
`mongodb://${process.env.NUBIAN_MONGO_HOST}/nubian?authSource=admin`,
|
||||||
{
|
{
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
user: "admin",
|
user: process.env.NUBIAN_MONGO_USERNAME,
|
||||||
pass: process.env.ALEXANDRIA_DATABASE_PASSWORD,
|
pass: process.env.NUBIAN_MONGO_PASSWORD,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,8 @@ const userUpload = multer({
|
||||||
|
|
||||||
//Helper Methods
|
//Helper Methods
|
||||||
function userUploadDestination(user_id) {
|
function userUploadDestination(user_id) {
|
||||||
if (!fs.existsSync(resolvePath(process.env.KHUFU_UPLOAD_PATH)))
|
if (!fs.existsSync("uploads")) fs.mkdirSync("uploads");
|
||||||
fs.mkdirSync(resolvePath(process.env.KHUFU_UPLOAD_PATH));
|
const destination = resolvePath(`uploads/${user_id}`);
|
||||||
const destination = resolvePath(process.env.KHUFU_UPLOAD_PATH, `${user_id}`);
|
|
||||||
if (!fs.existsSync(destination)) fs.mkdirSync(destination);
|
if (!fs.existsSync(destination)) fs.mkdirSync(destination);
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ const timeout = 10 * 60 * 1000; // 10 minutes
|
||||||
app.use(bearerToken());
|
app.use(bearerToken());
|
||||||
app.use(bodyParser.json({ limit: Server.BodyLimit }));
|
app.use(bodyParser.json({ limit: Server.BodyLimit }));
|
||||||
app.use(bodyParser.urlencoded({ limit: Server.BodyLimit, extended: false }));
|
app.use(bodyParser.urlencoded({ limit: Server.BodyLimit, extended: false }));
|
||||||
app.use(["/nubian/api/stash", "/api/stash", "/stash"], stashRouter);
|
app.use(require("./routes/vitals-router"));
|
||||||
|
app.use("/api/stash", stashRouter);
|
||||||
const startServer = () => {
|
const startServer = () => {
|
||||||
var server = app.listen(port, () => {
|
var server = app.listen(port, () => {
|
||||||
console.log("Node version:" + process.versions.node);
|
console.log("Node version:" + process.versions.node);
|
||||||
|
|
|
@ -13,7 +13,7 @@ const cairoMiddleware = (req, res, next) => {
|
||||||
if (req.token == null) return next();
|
if (req.token == null) return next();
|
||||||
else
|
else
|
||||||
axios
|
axios
|
||||||
.get(`${process.env.CAIRO_PUBLIC_URL}/user/data`, {
|
.get(`${process.env.CAIRO_URL}/api/user/info`, {
|
||||||
headers: { authorization: `Bearer ${req.token}` },
|
headers: { authorization: `Bearer ${req.token}` },
|
||||||
})
|
})
|
||||||
.then((authRes) => {
|
.then((authRes) => {
|
||||||
|
|
4
src/routes/vitals-router.js
Normal file
4
src/routes/vitals-router.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
const router = require("express").Router();
|
||||||
|
router.get("/healthcheck", (req, res) => res.sendStatus(200));
|
||||||
|
router.get("/alive", (req, res) => res.sendStatus(200));
|
||||||
|
module.exports = router;
|
|
@ -8,7 +8,7 @@ const file = new Schema(
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
owner: { type: ObjId, ref: "user" },
|
owner: { type: String},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
Reference in a new issue