Added: tests, signin api, not working docker

This commit is contained in:
2024-05-01 23:24:03 +02:00
parent dc1b955a8a
commit bd8a5d607f
14 changed files with 553 additions and 83 deletions

View File

@ -0,0 +1,30 @@
const mongoose = require('mongoose');
const { MongoMemoryServer } = require('mongodb-memory-server');
let mongo: any = null;
const connectDB = async () => {
mongo = await MongoMemoryServer.create({ binary: { os: { os: 'linux', dist: 'ubuntu', release: '18.04' } } }); // TODO: check that host OS is Void Linux, else remove the argument
const uri = mongo.getUri();
await mongoose.connect(uri);
};
const dropDB = async () => {
if (mongo) {
await mongoose.connection.dropDatabase();
await mongoose.connection.close();
await mongo.stop();
}
};
const dropCollections = async () => {
if (mongo) {
const collections = await mongoose.connection.db.collections();
for (let collection of collections) {
await collection.remove();
}
}
};
export { connectDB, dropDB, dropCollections };