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 { AccessTokens } from './mongodb';
|
||||||
import type AccessToken from '../types/AccessToken';
|
import type AccessToken from '../../types/AccessToken';
|
||||||
import { createHash } from 'crypto';
|
import { createHash } from 'crypto';
|
||||||
|
|
||||||
export const createAccessToken = async (accessToken: AccessToken) => {
|
export const createAccessToken = async (accessToken: AccessToken) => {
|
||||||
|
@ -38,6 +38,5 @@ export const getAllAccessTokens = async () => {
|
||||||
const accessTokens = await AccessTokens();
|
const accessTokens = await AccessTokens();
|
||||||
const arrayOfTokens = await accessTokens.find({}).toArray() as AccessToken[];
|
const arrayOfTokens = await accessTokens.find({}).toArray() as AccessToken[];
|
||||||
let arr = [master].concat(arrayOfTokens);
|
let arr = [master].concat(arrayOfTokens);
|
||||||
// return accessTokens.find({}).toArray() as Promise<AccessToken[]>;
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import { Users } from './mongodb';
|
import { Users } from '../db/mongodb';
|
||||||
import type User from '../types/User';
|
import type User from '../../types/User';
|
||||||
import type Resources from '../types/Resources';
|
import type Resources from '../../types/Resources';
|
||||||
|
|
||||||
export const getAllUsers = async () => {
|
export const getAllUsers = async () => {
|
||||||
const users = await Users();
|
const users = await Users();
|
|
@ -1,5 +1,5 @@
|
||||||
import type AccessToken from "../../types/AccessToken";
|
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> {
|
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];
|
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 Layout from "../../layouts/Layout.astro";
|
||||||
import { getAllAccessTokens } from "../../lib/accessTokens";
|
import { getAllAccessTokens } from "../../lib/db/accessTokens";
|
||||||
|
|
||||||
const tokens = await getAllAccessTokens();
|
const tokens = await getAllAccessTokens();
|
||||||
|
|
||||||
|
@ -43,5 +43,7 @@ const type = {
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
color: white;
|
color: white;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -1,7 +1,7 @@
|
||||||
import { randomBytes, createHash } from "crypto";
|
import { randomBytes, createHash } from "crypto";
|
||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import type AccessToken from "../../../types/AccessToken";
|
import type AccessToken from "../../../types/AccessToken";
|
||||||
import { createAccessToken } from "../../../lib/accessTokens";
|
import { createAccessToken } from "../../../lib/db/accessTokens";
|
||||||
|
|
||||||
export const POST: APIRoute = async({ request }) => {
|
export const POST: APIRoute = async({ request }) => {
|
||||||
const data = await request.json().catch(() => {return new Response(
|
const data = await request.json().catch(() => {return new Response(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
import Layout from '../../layouts/Layout.astro';
|
import Layout from '../../layouts/Layout.astro';
|
||||||
import NavBar from '../../components/NavBar.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';
|
import { getHighestWeightedLanguage, getLocales } from '../../lib/lang/langDriver';
|
||||||
|
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
|
@ -23,7 +23,6 @@ await updateUserResources(username, {
|
||||||
|
|
||||||
const langResources = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources');
|
const langResources = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources');
|
||||||
const langGame = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'game');
|
const langGame = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'game');
|
||||||
// console.log(resources);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="chujów sto">
|
<Layout title="chujów sto">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import Layout from '../layouts/Layout.astro';
|
import Layout from '../layouts/Layout.astro';
|
||||||
import NavBar from '../components/NavBar.astro';
|
import NavBar from '../components/NavBar.astro';
|
||||||
|
|
||||||
import { getUserByNickOrEmail } from '../lib/users';
|
import { getUserByNickOrEmail } from '../lib/db/users';
|
||||||
|
|
||||||
import { compare } from 'bcrypt';
|
import { compare } from 'bcrypt';
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import Layout from '../layouts/Layout.astro';
|
import Layout from '../layouts/Layout.astro';
|
||||||
import NavBar from '../components/NavBar.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 type User from '../types/User';
|
||||||
|
|
||||||
import bcrypt from 'bcrypt';
|
import bcrypt from 'bcrypt';
|
||||||
|
|
Loading…
Reference in New Issue