summaryrefslogtreecommitdiff
path: root/api/db/_tables.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/db/_tables.ts')
-rw-r--r--api/db/_tables.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/api/db/_tables.ts b/api/db/_tables.ts
new file mode 100644
index 0000000..8ec5cb5
--- /dev/null
+++ b/api/db/_tables.ts
@@ -0,0 +1,50 @@
+import type Authenticator from '../types/Authenticator';
+import type Subscription from '../types/Subscription';
+import type User from '../types/User';
+
+import env from '../_env';
+
+const prefix = env.ENVIRONMENT === 'prod' ? '' : 'dev_';
+
+type TableSchema<Model> = {
+ name: string,
+ fields: { [key in keyof Model]: string },
+};
+
+export const AUTHENTICATORS: TableSchema<Authenticator> = {
+ name: `${prefix}authenticators`,
+ fields: {
+ id: 'id',
+ backedUp: 'backed_up',
+ counter: 'counter',
+ deviceType: 'device_type',
+ publicKey: 'public_key',
+ transports: 'transports',
+ type: 'type',
+ userId: 'user_id',
+ },
+};
+
+export const CURRENT_CHALLENGES: TableSchema<{ userId: User['id'], currentChallenge: string }> = {
+ name: `${prefix}current_challenges`,
+ fields: {
+ userId: 'user_id',
+ currentChallenge: 'current_challenge',
+ },
+};
+
+export const SUBSCRIPTIONS: TableSchema<Subscription> = {
+ name: `${prefix}subscriptions`,
+ fields: {
+ id: 'id',
+ emailAddress: 'email_address',
+ },
+};
+
+export const USERS: TableSchema<User> = {
+ name: `${prefix}users`,
+ fields: {
+ id: 'id',
+ displayName: 'display_name',
+ },
+};