typeorm api rewrite done

This commit is contained in:
Flam3rboy
2021-08-29 00:03:40 +02:00
parent c21c342821
commit e99008a1a5
48 changed files with 465 additions and 991 deletions
-40
View File
@@ -1,40 +0,0 @@
import mongoose, { Schema, Types } from "mongoose";
require("mongoose-long")(mongoose);
const userSchema = new Schema({
id: String
});
const messageSchema = new Schema({
id: String,
content: String
});
const message = mongoose.model("message", messageSchema, "messages");
const user = mongoose.model("user", userSchema, "users");
messageSchema.virtual("u", {
ref: user,
localField: "id",
foreignField: "id",
justOne: true
});
messageSchema.set("toObject", { virtuals: true });
messageSchema.set("toJSON", { virtuals: true });
async function main() {
const conn = await mongoose.connect("mongodb://localhost:27017/lambert?readPreference=secondaryPreferred", {
useNewUrlParser: true,
useUnifiedTopology: false
});
console.log("connected");
// const u = await new user({ name: "test" }).save();
// await new message({ user: u._id, content: "test" }).save();
const test = await message.findOneOrFail({}).populate("u");
// @ts-ignore
console.log(test?.toJSON());
}
main();
-39
View File
@@ -1,39 +0,0 @@
// @ts-nocheck
import "missing-native-js-functions";
import { config } from "dotenv";
config();
import { DiscordServer } from "../Server";
import fetch from "node-fetch";
import { promises } from "fs";
const count = 100;
async function main() {
const server = new DiscordServer({ port: 3000 });
await server.start();
const tasks = [];
for (let i = 0; i < count; i++) {
tasks.push(test());
}
await Promise.all(tasks);
console.log("logging in 5secs");
setTimeout(async () => {
await test();
process.exit();
}, 5000);
}
main();
async function test() {
const res = await fetch("http://localhost:3000/api/v8/guilds/813524615463698433/members/813524464300982272", {
headers: {
authorization:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMzUyNDQ2NDMwMDk4MjI3MiIsImlhdCI6MTYxNDAyOTc0Nn0.6WQiU4D5HHRi3sliHOQe1hsW-hZTEttvdtZuNIdviNI",
},
});
return await res.text();
}
-3
View File
@@ -1,3 +0,0 @@
import { Snowflake } from "@fosscord/util";
console.log(Snowflake.deconstruct("0"));