diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx new file mode 100644 index 000000000..f21fe4708 --- /dev/null +++ b/src/app/admin/layout.tsx @@ -0,0 +1,21 @@ +import { getServerSession } from 'next-auth'; +import { notFound, redirect } from 'next/navigation'; +import React from 'react'; + +export default async function AdminLayout({ + children, +}: { + children: React.ReactNode; +}) { + const session = await getServerSession(); + + if (!session || !session.user) { + return redirect('/signin'); + } + + if (!process.env.ADMINS?.split(',').includes(session.user.email!)) { + return notFound(); + } + + return <>{children}; +} diff --git a/src/db/Cache.ts b/src/db/Cache.ts index 141ee455c..da447951c 100644 --- a/src/db/Cache.ts +++ b/src/db/Cache.ts @@ -26,7 +26,12 @@ export class Cache { return this.instance; } - set(type: string, args: string[], value: any, expirySeconds: number = parseInt(process.env.CACHE_EXPIRE_S || '100', 10)) { + set( + type: string, + args: string[], + value: any, + expirySeconds: number = parseInt(process.env.CACHE_EXPIRE_S || '100', 10), + ) { this.inMemoryDb.set(`${type} ${JSON.stringify(args)}`, { value, expiry: new Date().getTime() + expirySeconds * 1000, @@ -46,7 +51,5 @@ export class Cache { return entry.value; } - evict() { - - } + evict() {} } diff --git a/yarn.lock b/yarn.lock index 552adebbc..370414795 100644 --- a/yarn.lock +++ b/yarn.lock @@ -351,15 +351,10 @@ resolved "https://registry.npmjs.org/@next/env/-/env-14.0.2.tgz" integrity sha512-HAW1sljizEaduEOes/m84oUqeIDAUYBR1CDwu2tobNlNDFP3cSm9d6QsOsGeNlIppU1p/p1+bWbYCbvwjFiceA== -"@next/swc-linux-x64-gnu@14.0.2": +"@next/swc-darwin-arm64@14.0.2": version "14.0.2" - resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.2.tgz" - integrity sha512-WC9KAPSowj6as76P3vf1J3mf2QTm3Wv3FBzQi7UJ+dxWjK3MhHVWsWUo24AnmHx9qDcEtHM58okgZkXVqeLB+Q== - -"@next/swc-linux-x64-musl@14.0.2": - version "14.0.2" - resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.2.tgz" - integrity sha512-KSSAwvUcjtdZY4zJFa2f5VNJIwuEVnOSlqYqbQIawREJA+gUI6egeiRu290pXioQXnQHYYdXmnVNZ4M+VMB7KQ== + resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.2.tgz" + integrity sha512-i+jQY0fOb8L5gvGvojWyZMfQoQtDVB2kYe7fufOEiST6sicvzI2W5/EXo4lX5bLUjapHKe+nFxuVv7BA+Pd7LQ== "@nodelib/fs.scandir@2.1.5": version "2.1.5" @@ -2101,6 +2096,11 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"