mirror of
https://github.com/Permissionless-Software-Foundation/x402-base-facilitator.git
synced 2026-09-21 16:52:01 -07:00
25 lines
602 B
JavaScript
25 lines
602 B
JavaScript
import mongoose from 'mongoose'
|
|
|
|
export function cleanDb() {
|
|
for (const collection in mongoose.connection.collections) {
|
|
if (mongoose.connection.collections.hasOwnProperty(collection)) {
|
|
mongoose.connection.collections[collection].remove()
|
|
}
|
|
}
|
|
}
|
|
|
|
export function authUser(agent, callback) {
|
|
agent
|
|
.post('/users')
|
|
.set('Accept', 'application/json')
|
|
.send({ user: { username: 'test', password: 'pass' } })
|
|
.end((err, res) => {
|
|
if (err) { return callback(err) }
|
|
|
|
callback(null, {
|
|
user: res.body.user,
|
|
token: res.body.token
|
|
})
|
|
})
|
|
}
|