Move database-related files to "db" subdir
This commit is contained in:
parent
79f0c3a1d6
commit
fe53185779
|
@ -1,5 +1,5 @@
|
|||
import { AccessTokens } from './mongodb';
|
||||
import type AccessToken from '../types/AccessToken';
|
||||
import type AccessToken from '../../types/AccessToken';
|
||||
import { createHash } from 'crypto';
|
||||
|
||||
export const createAccessToken = async (accessToken: AccessToken) => {
|
||||
|
@ -38,6 +38,5 @@ export const getAllAccessTokens = async () => {
|
|||
const accessTokens = await AccessTokens();
|
||||
const arrayOfTokens = await accessTokens.find({}).toArray() as AccessToken[];
|
||||
let arr = [master].concat(arrayOfTokens);
|
||||
// return accessTokens.find({}).toArray() as Promise<AccessToken[]>;
|
||||
return arr;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Users } from './mongodb';
|
||||
import type User from '../types/User';
|
||||
import type Resources from '../types/Resources';
|
||||
import { Users } from '../db/mongodb';
|
||||
import type User from '../../types/User';
|
||||
import type Resources from '../../types/Resources';
|
||||
|
||||
export const getAllUsers = async () => {
|
||||
const users = await Users();
|
|
@ -1,5 +1,5 @@
|
|||
import type AccessToken from "../../types/AccessToken";
|
||||
import { getAccessToken } from "../accessTokens";
|
||||
import { getAccessToken } from "../db/accessTokens";
|
||||
|
||||
export default async function validateAccessToken(request: Request): Promise<Response | AccessToken> {
|
||||
const accessToken = request.url.split("?")[1]?.split("&").filter((x) => x.split("=")[0] === "token")[0].split("=")[1];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import { getAllAccessTokens } from "../../lib/accessTokens";
|
||||
import { getAllAccessTokens } from "../../lib/db/accessTokens";
|
||||
|
||||
const tokens = await getAllAccessTokens();
|
||||
|
||||
|
@ -43,5 +43,7 @@ const type = {
|
|||
<style>
|
||||
* {
|
||||
color: white;
|
||||
font-family: monospace;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
|
@ -1,7 +1,7 @@
|
|||
import { randomBytes, createHash } from "crypto";
|
||||
import type { APIRoute } from "astro";
|
||||
import type AccessToken from "../../../types/AccessToken";
|
||||
import { createAccessToken } from "../../../lib/accessTokens";
|
||||
import { createAccessToken } from "../../../lib/db/accessTokens";
|
||||
|
||||
export const POST: APIRoute = async({ request }) => {
|
||||
const data = await request.json().catch(() => {return new Response(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import NavBar from '../../components/NavBar.astro';
|
||||
import { getUserResources, updateUserResources } from '../../lib/users';
|
||||
import { getUserResources, updateUserResources } from '../../lib/db/users';
|
||||
import { getHighestWeightedLanguage, getLocales } from '../../lib/lang/langDriver';
|
||||
|
||||
String.prototype.format = function() {
|
||||
|
@ -23,7 +23,6 @@ await updateUserResources(username, {
|
|||
|
||||
const langResources = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources');
|
||||
const langGame = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'game');
|
||||
// console.log(resources);
|
||||
---
|
||||
|
||||
<Layout title="chujów sto">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Layout from '../layouts/Layout.astro';
|
||||
import NavBar from '../components/NavBar.astro';
|
||||
|
||||
import { getUserByNickOrEmail } from '../lib/users';
|
||||
import { getUserByNickOrEmail } from '../lib/db/users';
|
||||
|
||||
import { compare } from 'bcrypt';
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Layout from '../layouts/Layout.astro';
|
||||
import NavBar from '../components/NavBar.astro';
|
||||
|
||||
import { createUser } from '../lib/users';
|
||||
import { createUser } from '../lib/db/users';
|
||||
import type User from '../types/User';
|
||||
|
||||
import bcrypt from 'bcrypt';
|
||||
|
|
Loading…
Reference in New Issue