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