Compare commits

...

2 Commits

Author SHA1 Message Date
iamBadgers
a2a51754f7 partial work on initting protos 2025-06-07 22:28:16 -07:00
iamBadgers
7d13bc0c47 cleanup vault packages 2025-06-07 22:20:44 -07:00
12 changed files with 1432 additions and 5582 deletions

View File

@@ -27,6 +27,10 @@ services:
- rush-character-net
ports:
- 8081:8080
environment:
MONGO_URI: mongodb://rushvault:rushvault@mongo:27017/
depends_on:
- mongo
develop:
watch:
- action: sync
@@ -45,11 +49,20 @@ services:
environment:
MONGO_INITDB_ROOT_USERNAME: rushvault
MONGO_INITDB_ROOT_PASSWORD: rushvault
MONGO_INITDB_DATABASE: DB
networks:
- rush-character-net
ports:
- 27017:27017
mongo-express:
image: mongo-express
restart: always
networks:
- rush-character-net
ports:
- 8083:8081
depends_on:
- mongo
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: rushvault
ME_CONFIG_MONGODB_ADMINPASSWORD: rushvault

View File

@@ -1,33 +0,0 @@
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": {
}
}

3
vault/.prettierignore Normal file
View File

@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage

11
vault/eslint.config.mjs Normal file
View File

@@ -0,0 +1,11 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import { defineConfig } from "eslint/config";
export default defineConfig([
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"] },
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], languageOptions: { globals: globals.node } },
tseslint.configs.recommended,
]);

6482
vault/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,44 +1,34 @@
{
"name": "vault",
"version": "1.0.0",
"description": "",
"description": "backend for rush cahracter archive",
"main": "index.js",
"scripts": {
"build_protos": "protoc --ts_out=src ./proto/*",
"build": "protoc --ts_out=src ./proto/* && tsc",
"start": "protoc --ts_out=src ./proto/* && tsc && node dist/app.js",
"dev": "protoc --ts_out=src ./proto/* npx ts-node-dev src/app.ts",
"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"
"format": "npx prettier . --write",
"lint": "npx eslint . --ext .ts"
},
"keywords": [],
"author": "",
"author": "iamBadgers",
"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"
"@eslint/js": "^9.28.0",
"@types/express": "^5.0.3",
"@types/node": "^22.15.30",
"eslint": "^9.28.0",
"globals": "^16.2.0",
"prettier": "3.5.3",
"ts-node": "^10.9.2",
"typescript": "^5.8.3",
"typescript-eslint": "^8.33.1"
},
"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"
"@grpc/grpc-js": "^1.13.4",
"@protobuf-ts/protoc": "^2.11.0",
"express": "^5.1.0",
"mongodb": "^6.17.0"
}
}

View File

@@ -0,0 +1,20 @@
syntax = "proto3";
service CharacterManager {
rpc createCharacter(CreateCharacterRequest) returns (CreateCharacterResponse);
rpc getCharacter(GetCharacterRequest) returns (GetCharacterResponse);
}
message Character {
string PlayerName = 1;
string CharacterName = 2;
repeated string CharacterAlias = 3;
}
message CreateCharacterRequest {}
message CreateCharacterResponse {}
message GetCharacterRequest {}
message GetCharacterResponse {}

View File

@@ -1,9 +1,7 @@
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!')
@@ -11,6 +9,4 @@ app.get('/api/person', async (req, res) => {
app.listen(8080, async () => {
console.log('starting on 8080')
dbClient.connect()
console.log(await dbClient.query('SELECT NOW()'))
})

View File

@@ -1,24 +0,0 @@
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 })
// }
// }

View File

@@ -0,0 +1,340 @@
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 6.31.0
* source: proto/character.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
import * as grpc_1 from "@grpc/grpc-js";
export class Character extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
PlayerName?: string;
CharacterName?: string;
CharacterAlias?: string[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("PlayerName" in data && data.PlayerName != undefined) {
this.PlayerName = data.PlayerName;
}
if ("CharacterName" in data && data.CharacterName != undefined) {
this.CharacterName = data.CharacterName;
}
if ("CharacterAlias" in data && data.CharacterAlias != undefined) {
this.CharacterAlias = data.CharacterAlias;
}
}
}
get PlayerName() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set PlayerName(value: string) {
pb_1.Message.setField(this, 1, value);
}
get CharacterName() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set CharacterName(value: string) {
pb_1.Message.setField(this, 2, value);
}
get CharacterAlias() {
return pb_1.Message.getFieldWithDefault(this, 3, []) as string[];
}
set CharacterAlias(value: string[]) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
PlayerName?: string;
CharacterName?: string;
CharacterAlias?: string[];
}): Character {
const message = new Character({});
if (data.PlayerName != null) {
message.PlayerName = data.PlayerName;
}
if (data.CharacterName != null) {
message.CharacterName = data.CharacterName;
}
if (data.CharacterAlias != null) {
message.CharacterAlias = data.CharacterAlias;
}
return message;
}
toObject() {
const data: {
PlayerName?: string;
CharacterName?: string;
CharacterAlias?: string[];
} = {};
if (this.PlayerName != null) {
data.PlayerName = this.PlayerName;
}
if (this.CharacterName != null) {
data.CharacterName = this.CharacterName;
}
if (this.CharacterAlias != null) {
data.CharacterAlias = this.CharacterAlias;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.PlayerName.length)
writer.writeString(1, this.PlayerName);
if (this.CharacterName.length)
writer.writeString(2, this.CharacterName);
if (this.CharacterAlias.length)
writer.writeRepeatedString(3, this.CharacterAlias);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Character {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Character();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.PlayerName = reader.readString();
break;
case 2:
message.CharacterName = reader.readString();
break;
case 3:
pb_1.Message.addToRepeatedField(message, 3, reader.readString());
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Character {
return Character.deserialize(bytes);
}
}
export class CreateCharacterRequest extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}): CreateCharacterRequest {
const message = new CreateCharacterRequest({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CreateCharacterRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CreateCharacterRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CreateCharacterRequest {
return CreateCharacterRequest.deserialize(bytes);
}
}
export class CreateCharacterResponse extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}): CreateCharacterResponse {
const message = new CreateCharacterResponse({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CreateCharacterResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CreateCharacterResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CreateCharacterResponse {
return CreateCharacterResponse.deserialize(bytes);
}
}
export class GetCharacterRequest extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}): GetCharacterRequest {
const message = new GetCharacterRequest({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GetCharacterRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GetCharacterRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GetCharacterRequest {
return GetCharacterRequest.deserialize(bytes);
}
}
export class GetCharacterResponse extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}): GetCharacterResponse {
const message = new GetCharacterResponse({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GetCharacterResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GetCharacterResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GetCharacterResponse {
return GetCharacterResponse.deserialize(bytes);
}
}
interface GrpcUnaryServiceInterface<P, R> {
(message: P, metadata: grpc_1.Metadata, options: grpc_1.CallOptions, callback: grpc_1.requestCallback<R>): grpc_1.ClientUnaryCall;
(message: P, metadata: grpc_1.Metadata, callback: grpc_1.requestCallback<R>): grpc_1.ClientUnaryCall;
(message: P, options: grpc_1.CallOptions, callback: grpc_1.requestCallback<R>): grpc_1.ClientUnaryCall;
(message: P, callback: grpc_1.requestCallback<R>): grpc_1.ClientUnaryCall;
}
interface GrpcStreamServiceInterface<P, R> {
(message: P, metadata: grpc_1.Metadata, options?: grpc_1.CallOptions): grpc_1.ClientReadableStream<R>;
(message: P, options?: grpc_1.CallOptions): grpc_1.ClientReadableStream<R>;
}
interface GrpWritableServiceInterface<P, R> {
(metadata: grpc_1.Metadata, options: grpc_1.CallOptions, callback: grpc_1.requestCallback<R>): grpc_1.ClientWritableStream<P>;
(metadata: grpc_1.Metadata, callback: grpc_1.requestCallback<R>): grpc_1.ClientWritableStream<P>;
(options: grpc_1.CallOptions, callback: grpc_1.requestCallback<R>): grpc_1.ClientWritableStream<P>;
(callback: grpc_1.requestCallback<R>): grpc_1.ClientWritableStream<P>;
}
interface GrpcChunkServiceInterface<P, R> {
(metadata: grpc_1.Metadata, options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream<P, R>;
(options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream<P, R>;
}
interface GrpcPromiseServiceInterface<P, R> {
(message: P, metadata: grpc_1.Metadata, options?: grpc_1.CallOptions): Promise<R>;
(message: P, options?: grpc_1.CallOptions): Promise<R>;
}
export abstract class UnimplementedCharacterManagerService {
static definition = {
createCharacter: {
path: "/CharacterManager/createCharacter",
requestStream: false,
responseStream: false,
requestSerialize: (message: CreateCharacterRequest) => Buffer.from(message.serialize()),
requestDeserialize: (bytes: Buffer) => CreateCharacterRequest.deserialize(new Uint8Array(bytes)),
responseSerialize: (message: CreateCharacterResponse) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => CreateCharacterResponse.deserialize(new Uint8Array(bytes))
},
getCharacter: {
path: "/CharacterManager/getCharacter",
requestStream: false,
responseStream: false,
requestSerialize: (message: GetCharacterRequest) => Buffer.from(message.serialize()),
requestDeserialize: (bytes: Buffer) => GetCharacterRequest.deserialize(new Uint8Array(bytes)),
responseSerialize: (message: GetCharacterResponse) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => GetCharacterResponse.deserialize(new Uint8Array(bytes))
}
};
[method: string]: grpc_1.UntypedHandleCall;
abstract createCharacter(call: grpc_1.ServerUnaryCall<CreateCharacterRequest, CreateCharacterResponse>, callback: grpc_1.sendUnaryData<CreateCharacterResponse>): void;
abstract getCharacter(call: grpc_1.ServerUnaryCall<GetCharacterRequest, GetCharacterResponse>, callback: grpc_1.sendUnaryData<GetCharacterResponse>): void;
}
export class CharacterManagerClient extends grpc_1.makeGenericClientConstructor(UnimplementedCharacterManagerService.definition, "CharacterManager", {}) {
constructor(address: string, credentials: grpc_1.ChannelCredentials, options?: Partial<grpc_1.ChannelOptions>) {
super(address, credentials, options);
}
createCharacter: GrpcUnaryServiceInterface<CreateCharacterRequest, CreateCharacterResponse> = (message: CreateCharacterRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<CreateCharacterResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<CreateCharacterResponse>, callback?: grpc_1.requestCallback<CreateCharacterResponse>): grpc_1.ClientUnaryCall => {
return super.createCharacter(message, metadata, options, callback);
};
getCharacter: GrpcUnaryServiceInterface<GetCharacterRequest, GetCharacterResponse> = (message: GetCharacterRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<GetCharacterResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<GetCharacterResponse>, callback?: grpc_1.requestCallback<GetCharacterResponse>): grpc_1.ClientUnaryCall => {
return super.getCharacter(message, metadata, options, callback);
};
}

View File

@@ -8,4 +8,4 @@
"outDir": "dist"
},
"lib": ["es2015"]
}
}

View File

@@ -1,30 +0,0 @@
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()],
};