Compare commits

..

2 Commits

Author SHA1 Message Date
Aelita4 503e8e34dd
Add support for connecting to MongoDB Atlas 2024-09-23 13:05:11 +02:00
Aelita4 2e8230ee60
Fix bug with logging in 2024-09-23 13:04:47 +02:00
3 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ pnpm-debug.log*
.env
.env.production
config.json
certs/
# macOS-specific files
.DS_Store

View File

@ -6,7 +6,17 @@ import AccessToken from '../../types/AccessToken';
import locationManager from '../classes/managers/LocationManager';
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;
}

View File

@ -2,7 +2,9 @@ import { MongoClient } from "mongodb";
import config from '../../../config.json'
const uri = config.MONGODB_URI;
const options = {};
const options = {
tlsCertificateKeyFile: config.MONGODB_CERT
};
const mongo = new MongoClient(uri, options);