mirror of
https://github.com/spacebarchat/server.git
synced 2026-09-16 17:12:39 +00:00
✨ typeorm api rewrite done
This commit is contained in:
@@ -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();
|
||||
@@ -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();
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
import { Snowflake } from "@fosscord/util";
|
||||
|
||||
console.log(Snowflake.deconstruct("0"));
|
||||
Reference in New Issue
Block a user