Compare commits
2 Commits
cc5d482a0f
...
503e8e34dd
Author | SHA1 | Date |
---|---|---|
Aelita4 | 503e8e34dd | |
Aelita4 | 2e8230ee60 |
|
@ -17,6 +17,7 @@ pnpm-debug.log*
|
||||||
.env
|
.env
|
||||||
.env.production
|
.env.production
|
||||||
config.json
|
config.json
|
||||||
|
certs/
|
||||||
|
|
||||||
# macOS-specific files
|
# macOS-specific files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
@ -6,7 +6,17 @@ import AccessToken from '../../types/AccessToken';
|
||||||
import locationManager from '../classes/managers/LocationManager';
|
import locationManager from '../classes/managers/LocationManager';
|
||||||
|
|
||||||
export const createAccessToken = async (accessToken: AccessToken) => {
|
export const createAccessToken = async (accessToken: AccessToken) => {
|
||||||
const newAccessToken = await (await AccessTokens()).insertOne(accessToken);
|
const formatted: DBAccessToken = {
|
||||||
|
_id: new ObjectId(),
|
||||||
|
type: accessToken.type,
|
||||||
|
user: accessToken.user?.id ?? new ObjectId(0),
|
||||||
|
entropy: accessToken.entropy,
|
||||||
|
createdAt: accessToken.createdAt,
|
||||||
|
expiresAt: accessToken.expiresAt ?? new Date(accessToken.createdAt.getTime() + 86400000),
|
||||||
|
createdFrom: accessToken.createdFrom
|
||||||
|
}
|
||||||
|
|
||||||
|
const newAccessToken = await (await AccessTokens()).insertOne(formatted);
|
||||||
return newAccessToken;
|
return newAccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@ import { MongoClient } from "mongodb";
|
||||||
import config from '../../../config.json'
|
import config from '../../../config.json'
|
||||||
|
|
||||||
const uri = config.MONGODB_URI;
|
const uri = config.MONGODB_URI;
|
||||||
const options = {};
|
const options = {
|
||||||
|
tlsCertificateKeyFile: config.MONGODB_CERT
|
||||||
|
};
|
||||||
|
|
||||||
const mongo = new MongoClient(uri, options);
|
const mongo = new MongoClient(uri, options);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue