mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-06 13:40:16 +08:00
remove unused function in userDal, rename requests to connections
This commit is contained in:
parent
3049302317
commit
4b9e275a13
3 changed files with 9 additions and 33 deletions
|
@ -18,7 +18,7 @@ import { Connection } from "@monkeytype/schemas/connections";
|
|||
function convert(db: ConnectionsDal.DBConnection): Connection {
|
||||
return replaceObjectId(omit(db, "key"));
|
||||
}
|
||||
export async function getRequests(
|
||||
export async function getConnections(
|
||||
req: MonkeyRequest<GetConnectionsQuery>
|
||||
): Promise<GetConnectionsResponse> {
|
||||
const { uid } = req.ctx.decodedToken;
|
||||
|
@ -35,7 +35,7 @@ export async function getRequests(
|
|||
return new MonkeyResponse("Connections retrieved", results.map(convert));
|
||||
}
|
||||
|
||||
export async function createRequest(
|
||||
export async function createConnection(
|
||||
req: MonkeyRequest<undefined, CreateConnectionRequest>
|
||||
): Promise<CreateConnectionResponse> {
|
||||
const { uid } = req.ctx.decodedToken;
|
||||
|
@ -61,7 +61,7 @@ export async function createRequest(
|
|||
return new MonkeyResponse("Connection created", convert(result));
|
||||
}
|
||||
|
||||
export async function deleteRequest(
|
||||
export async function deleteConnection(
|
||||
req: MonkeyRequest<undefined, undefined, IdPathParams>
|
||||
): Promise<MonkeyResponse> {
|
||||
const { uid } = req.ctx.decodedToken;
|
||||
|
@ -72,7 +72,7 @@ export async function deleteRequest(
|
|||
return new MonkeyResponse("Connection deleted", null);
|
||||
}
|
||||
|
||||
export async function updateRequest(
|
||||
export async function updateConnection(
|
||||
req: MonkeyRequest<undefined, UpdateConnectionRequest, IdPathParams>
|
||||
): Promise<MonkeyResponse> {
|
||||
const { uid } = req.ctx.decodedToken;
|
||||
|
|
|
@ -7,18 +7,19 @@ import * as ConnectionsController from "../controllers/connections";
|
|||
const s = initServer();
|
||||
export default s.router(connectionsContract, {
|
||||
get: {
|
||||
handler: async (r) => callController(ConnectionsController.getRequests)(r),
|
||||
handler: async (r) =>
|
||||
callController(ConnectionsController.getConnections)(r),
|
||||
},
|
||||
create: {
|
||||
handler: async (r) =>
|
||||
callController(ConnectionsController.createRequest)(r),
|
||||
callController(ConnectionsController.createConnection)(r),
|
||||
},
|
||||
delete: {
|
||||
handler: async (r) =>
|
||||
callController(ConnectionsController.deleteRequest)(r),
|
||||
callController(ConnectionsController.deleteConnection)(r),
|
||||
},
|
||||
update: {
|
||||
handler: async (r) =>
|
||||
callController(ConnectionsController.updateRequest)(r),
|
||||
callController(ConnectionsController.updateConnection)(r),
|
||||
},
|
||||
});
|
||||
|
|
|
@ -268,31 +268,6 @@ export async function getPartialUser<K extends keyof DBUser>(
|
|||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users document only containing requested fields
|
||||
* @param uids user ids
|
||||
* @param stack stack description used in the error
|
||||
* @param fields list of fields
|
||||
* @returns map of userids with partial DBUser only containing requested fields
|
||||
*/
|
||||
/*export async function getPartialUsers<K extends keyof DBUser>(
|
||||
uids: string[],
|
||||
stack: string,
|
||||
fields: K[]
|
||||
): Promise<Record<string, Pick<DBUser, K>>> {
|
||||
const projection = new Map(fields.map((it) => [it, 1]));
|
||||
const results = await getUsersCollection().find(
|
||||
{ uid: { $in: uids } },
|
||||
{ projection }
|
||||
);
|
||||
if (results === null) return {};
|
||||
|
||||
return Object.fromEntries(
|
||||
(await results.toArray()).map((it) => [it.uid, it])
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
export async function findByName(name: string): Promise<DBUser | undefined> {
|
||||
const found = await getUsersCollection().findOne(
|
||||
{ name },
|
||||
|
|
Loading…
Add table
Reference in a new issue