user create wip
This commit is contained in:
16
api/src/framework/mongo/mongo.ts
Normal file
16
api/src/framework/mongo/mongo.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { MongoClient, Db } from "mongodb";
|
||||
|
||||
class Mongo {
|
||||
private client: MongoClient;
|
||||
private dbName: string;
|
||||
|
||||
constructor(uri: string) {
|
||||
this.client = new MongoClient(uri);
|
||||
}
|
||||
|
||||
getDb(): Db {
|
||||
return this.client.db(this.dbName);
|
||||
}
|
||||
}
|
||||
|
||||
export default Mongo;
|
14
api/src/framework/mongo/user.ts
Normal file
14
api/src/framework/mongo/user.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { CreateUserBody, User, UserInfo } from "@core";
|
||||
import { Services } from "../express/server";
|
||||
|
||||
export function Create(services: Services): (tracker: string, user: CreateUserBody) => Promise<UserInfo> {
|
||||
const { db } = services;
|
||||
const coll = db.collection("users");
|
||||
|
||||
return async (tracker, user) => {
|
||||
await coll.insertOne(user);
|
||||
return {
|
||||
name: "test"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user