1- import mongoose from ' mongoose' ;
2- import showdown from ' showdown' ;
1+ import mongoose from " mongoose" ;
2+ import showdown from " showdown" ;
33
4- import Note from ' ./note.model' ;
4+ import Note from " ./note.model" ;
55
6- import { getRepoOwnerType , checkUserIsACollaborator } from '../../../../utils/githubapi' ;
6+ import {
7+ getRepoOwnerType ,
8+ checkUserIsACollaborator ,
9+ } from "../../../../utils/githubapi" ;
710
811const converter = new showdown . Converter ( ) ;
912
@@ -29,10 +32,12 @@ async function createNote(user, noteDetails) {
2932 userName,
3033 accessToken,
3134 } ) ;
35+
3236 if ( ! userHasAccessToRepo ) {
3337 return {
3438 status : 400 ,
35- message : 'You cannot add private notes to this repository since you are not a collaborator' ,
39+ message :
40+ "You cannot add private notes to this repository since you are not a actual collaborator" ,
3641 } ;
3742 }
3843
@@ -54,19 +59,19 @@ async function createNote(user, noteDetails) {
5459 if ( ! userId ) {
5560 return {
5661 status : 400 ,
57- message : ' User id is required' ,
62+ message : " User id is required" ,
5863 } ;
5964 }
6065 if ( ! issueId ) {
6166 return {
6267 status : 400 ,
63- message : ' Issue id or Pull id is required' ,
68+ message : " Issue id or Pull id is required" ,
6469 } ;
6570 }
6671 if ( ! projectName ) {
6772 return {
6873 status : 400 ,
69- message : ' Project name is required' ,
74+ message : " Project name is required" ,
7075 } ;
7176 }
7277
@@ -87,13 +92,13 @@ async function createNote(user, noteDetails) {
8792 return {
8893 status : 200 ,
8994 data : newlyCreatedNote ,
90- message : ' Note created successfully' ,
95+ message : " Note created successfully" ,
9196 } ;
9297 } catch ( err ) {
9398 return {
9499 status : 401 ,
95100 data : { error : err } ,
96- message : ' Note not created' ,
101+ message : " Note not created" ,
97102 } ;
98103 }
99104}
@@ -120,10 +125,10 @@ async function getNotes(user, noteDetails) {
120125 { noteType } ,
121126 { $or : [ { userId } , { noteVisibility : true } ] } ,
122127 ] ,
123- } ) . populate ( ' userId' , ' userName avatarUrl githubId' ) ;
128+ } ) . populate ( " userId" , " userName avatarUrl githubId" ) ;
124129 const userDetails = { userName, avatarUrl, githubId } ;
125130
126- notes = notes . map ( note => ( {
131+ notes = notes . map ( ( note ) => ( {
127132 _id : note . _id ,
128133 noteContent : converter . makeHtml ( note . noteContent ) ,
129134 author : note . userId ,
@@ -137,13 +142,13 @@ async function getNotes(user, noteDetails) {
137142
138143 return {
139144 status : 200 ,
140- message : ' Fetched notes' ,
145+ message : " Fetched notes" ,
141146 data : notes ,
142147 } ;
143148 } catch ( err ) {
144149 return {
145150 status : 200 ,
146- message : ' Failed to fetch notes' ,
151+ message : " Failed to fetch notes" ,
147152 data : { error : err } ,
148153 } ;
149154 }
@@ -154,7 +159,7 @@ async function deleteNote(userId, noteDetails) {
154159 if ( ! noteId ) {
155160 return {
156161 status : 400 ,
157- message : ' Note id is required' ,
162+ message : " Note id is required" ,
158163 } ;
159164 }
160165
@@ -167,18 +172,18 @@ async function deleteNote(userId, noteDetails) {
167172 { projectName } ,
168173 { noteType } ,
169174 ] ,
170- } ) . populate ( ' userId' , ' userName avatarUrl githubId' ) ;
175+ } ) . populate ( " userId" , " userName avatarUrl githubId" ) ;
171176 if ( note ) note . remove ( ) ;
172177 return {
173178 status : 200 ,
174179 data : note ,
175- message : ' Note removed successfully' ,
180+ message : " Note removed successfully" ,
176181 } ;
177182 } catch ( err ) {
178183 return {
179184 status : 401 ,
180185 data : { error : err } ,
181- message : ' Invalid note id' ,
186+ message : " Invalid note id" ,
182187 } ;
183188 }
184189}
@@ -188,22 +193,25 @@ async function editNote(userId, noteDetails) {
188193 if ( ! noteId ) {
189194 return {
190195 status : 400 ,
191- message : ' Note id is required' ,
196+ message : " Note id is required" ,
192197 } ;
193198 }
194199
195200 try {
196- await Note . findOneAndUpdate ( { _id : mongoose . Types . ObjectId ( noteId ) } , { noteVisibility } ) ;
201+ await Note . findOneAndUpdate (
202+ { _id : mongoose . Types . ObjectId ( noteId ) } ,
203+ { noteVisibility }
204+ ) ;
197205
198206 return {
199207 status : 200 ,
200- message : ' Note updated successfully' ,
208+ message : " Note updated successfully" ,
201209 } ;
202210 } catch ( err ) {
203211 return {
204212 status : 401 ,
205213 data : { error : err } ,
206- message : ' Invalid note id' ,
214+ message : " Invalid note id" ,
207215 } ;
208216 }
209217}
0 commit comments