forked from b00tc4mp/isdi-parttime-202403
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create like and fix errors b00tc4mp#140
- Loading branch information
1 parent
1408e1f
commit 7114488
Showing
25 changed files
with
509 additions
and
240 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 28 additions & 10 deletions
38
staff/adrian-martin/socialcode/api/logic/createPost.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
import 'dotenv/config' | ||
import logic from './index.js' | ||
import { MongoClient } from 'mongodb' | ||
import data from '../data/index.js' | ||
|
||
try { | ||
logic.createPost('AdrianGon', 'smile4', 'https://imgs.search.brave.com/rY4vd7ChrTffot87xezWVyJZcsjp10UPNHx2EQMRCfs/rs:fit:860:0:0/g:ce/aHR0cHM6Ly9pLnBp/bmltZy5jb20vb3Jp/Z2luYWxzLzFiL2Qx/L2I2LzFiZDFiNjE1/ZTZkYTcwZGQ3MWRj/ODRmZDJmNDdjODBk/LmpwZw', 'hi 2', error => { | ||
if (error) { | ||
console.error(error) | ||
const { MONGODB_URL } = process.env | ||
const client = new MongoClient(MONGODB_URL) | ||
|
||
return | ||
} | ||
client.connect() | ||
.then(connection => { | ||
const db = connection.db('test') | ||
|
||
const users = db.collection('users') | ||
const posts = db.collection('posts') | ||
|
||
data.users = users | ||
data.posts = posts | ||
|
||
console.log('posts created') | ||
try { | ||
logic.createPost('AdrianGon', 'smile4', 'https://imgs.search.brave.com/rY4vd7ChrTffot87xezWVyJZcsjp10UPNHx2EQMRCfs/rs:fit:860:0:0/g:ce/aHR0cHM6Ly9pLnBp/bmltZy5jb20vb3Jp/Z2luYWxzLzFiL2Qx/L2I2LzFiZDFiNjE1/ZTZkYTcwZGQ3MWRj/ODRmZDJmNDdjODBk/LmpwZw', 'hi 2', error => { | ||
if (error) { | ||
console.error(error) | ||
|
||
return | ||
} | ||
|
||
console.log('posts created') | ||
}) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
}) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
.catch(error => console.error(error)) |
Oops, something went wrong.