add vault and mongo db with postgres in comments

This commit is contained in:
iamBadgers
2025-06-06 18:07:24 -07:00
parent 273cbf1558
commit 02007ffc94
11 changed files with 7851 additions and 3 deletions

View File

@@ -1,7 +1,12 @@
networks:
rush-character-net:
services: services:
rush-character-archive: rush-character-archive:
build: ./rush-character-archive build: ./rush-character-archive
command: npm run dev command: npm run dev
networks:
- rush-character-net
ports: ports:
- 8080:3000 - 8080:3000
develop: develop:
@@ -12,4 +17,56 @@ services:
ignore: ignore:
- node_modules - node_modules
- action: rebuild - action: rebuild
path: ./rush-character-archive/package.json path: ./rush-character-archive/package.json
- action: rebuild
path: ./rush-character-archive/Dockerfile
vault:
build: ./vault
command: npm run dev
networks:
- rush-character-net
ports:
- 8081:8080
develop:
watch:
- action: sync
path: ./vault
target: /srv/vault
ignore:
- node_modules
- action: rebuild
path: ./vault/package.json
- action: rebuild
path: ./vault/Dockerfile
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: rushvault
MONGO_INITDB_ROOT_PASSWORD: rushvault
mongo-express:
image: mongo-express
restart: always
ports:
- 8083:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: rushvault
ME_CONFIG_MONGODB_ADMINPASSWORD: rushvault
ME_CONFIG_MONGODB_URL: mongodb://rushvault:rushvault@mongo:27017/
ME_CONFIG_BASICAUTH: false
# db:
# image: postgres:17-bookworm
# networks:
# - rush-character-net
# environment:
# POSTGRES_USER: rushvault
# POSTGRES_PASSWORD: rushvault
# POSTGRES_DB: rushvault
# adminer:
# image: adminer
# networks:
# - rush-character-net
# ports:
# - 8082:8080

View File

@@ -32,8 +32,9 @@ const openReadmeInEditor = () => fetch('/__open-in-editor?file=README.md')
recommended IDE setup is recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a> <a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a>
+ +
<a href="https://github.com/vuejs/language-tools" target="_blank" rel="noopener">Vue - Official</a>. If <a href="https://github.com/vuejs/language-tools" target="_blank" rel="noopener"
you need to test your components and web pages, check out >Vue - Official</a
>. If you need to test your components and web pages, check out
<a href="https://vitest.dev/" target="_blank" rel="noopener">Vitest</a> <a href="https://vitest.dev/" target="_blank" rel="noopener">Vitest</a>
and and
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a> <a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a>

33
vault/.eslintrc.ts Normal file
View File

@@ -0,0 +1,33 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}

6
vault/.prettierrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"singleQuote": true,
"printWidth": 80
}

15
vault/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:22.16
WORKDIR /srv/vault
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
EXPOSE 8080
CMD ["node", "./dist/app.js"]

7611
vault/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

44
vault/package.json Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "vault",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/",
"dev": "npx ts-node-dev src/app.ts",
"build": "webpack && cp package.json ./dist/package.json"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/express": "^4.17.21",
"@types/sequelize": "^4.28.20",
"@types/sqlite3": "^3.1.11",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"crossenv": "^0.0.2-security",
"eslint": "^8.57.0",
"node-polyfill-webpack-plugin": "^4.0.0",
"prettier": "^3.2.5",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@types/body-parser": "^1.19.5",
"asty-astq": "^1.14.0",
"body-parser": "^1.20.2",
"express": "^4.21.2",
"memcached": "^2.2.2",
"net": "^1.0.2",
"pg": "^8.16.0",
"pg-hstore": "^2.3.4",
"sequelize": "^6.37.1",
"sqlite3": "^5.1.7",
"tokenizr": "^1.7.0",
"webpack-node-externals": "^3.0.0"
}
}

16
vault/src/app.ts Normal file
View File

@@ -0,0 +1,16 @@
import express from 'express'
import { buildClient } from './db'
const app = express()
const dbClient = buildClient('db', 'rushvault', 'rushvault', 'rushvault')
app.get('/api/person', async (req, res) => {
res.status(200).send('potato!')
})
app.listen(8080, async () => {
console.log('starting on 8080')
dbClient.connect()
console.log(await dbClient.query('SELECT NOW()'))
})

24
vault/src/db.ts Normal file
View File

@@ -0,0 +1,24 @@
import { Client } from 'pg'
export function buildClient(
host: string,
user: string,
password: string,
database: string,
) {
return new Client({ user, password, host, database })
}
// export class VaultDbClient {
// client: Client
// constructor(
// host: string,
// port: number,
// user: string,
// password: string,
// database: string,
// ) {
// this.client = new Client({ user, password, host, port, database })
// }
// }

11
vault/tsconfig.json Normal file
View File

@@ -0,0 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist"
},
"lib": ["es2015"]
}

30
vault/webpack.config.js Normal file
View File

@@ -0,0 +1,30 @@
const path = require('path');
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
const nodeExternals = require('webpack-node-externals');
module.exports = {
mode: 'production',
entry: './src/app.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
}, node: {
__dirname: false
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'app.js',
path: path.resolve(__dirname, './dist'),
},
plugins: [
new NodePolyfillPlugin(),
],
externals: [nodeExternals()],
};