mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-21 12:10:17 -04:00
feat: finished connected mongodb
This commit is contained in:
parent
ef1fd9d67e
commit
1c48408ecb
|
@ -1,5 +1,5 @@
|
||||||
NODE_ENV='dev'
|
NODE_ENV='dev'
|
||||||
APP_PORT=3000
|
APP_PORT=5000
|
||||||
DB_USER=
|
|
||||||
DB_PASS=
|
|
||||||
DB_URL=
|
DB_URL=
|
||||||
|
ION_CLIENT_ID=
|
||||||
|
ION_CLIENT_SECRET=
|
16
src/data.ts
16
src/data.ts
|
@ -1,5 +1,6 @@
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import { IonProfile } from './auth_ion';
|
import { IonProfile } from './auth_ion';
|
||||||
|
import { UserModel } from './models';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records users by id
|
* Records users by id
|
||||||
|
@ -77,15 +78,18 @@ export async function getUserByEmail(
|
||||||
export async function registerUserFromIonProfile(
|
export async function registerUserFromIonProfile(
|
||||||
profile: IonProfile
|
profile: IonProfile
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const id = v4();
|
const user = new UserModel({
|
||||||
const user: Carpool.User = {
|
id: v4(),
|
||||||
id,
|
|
||||||
username: profile.ion_username,
|
username: profile.ion_username,
|
||||||
email: profile.tj_email,
|
email: profile.tj_email,
|
||||||
first_name: profile.first_name,
|
first_name: profile.first_name,
|
||||||
last_name: profile.last_name,
|
last_name: profile.last_name,
|
||||||
};
|
});
|
||||||
users[id] = user;
|
|
||||||
|
user.save(function (err) {
|
||||||
|
if (err) return console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
console.log('Registered user', user);
|
console.log('Registered user', user);
|
||||||
return id;
|
return user.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,4 @@ const PoolSchema: Schema = new Schema({
|
||||||
|
|
||||||
const PoolModel = model('Pool', PoolSchema);
|
const PoolModel = model('Pool', PoolSchema);
|
||||||
|
|
||||||
export { UserModel, GroupModel, CommentModel };
|
export { UserModel, GroupModel, CommentModel, PoolModel };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user