feat : itunes api, docs, supabase auth #1
Conversation
… better understanding of auth flow
There was a problem hiding this comment.
Try to define all hardcoded strings in a constants file.
| }); | ||
|
|
||
| expect(res.statusCode).toEqual(200); | ||
| // expect(res.result.accessToken).toEqual('token'); |
There was a problem hiding this comment.
Remove this commented code if not required.
| import { badImplementation } from '@utils/responseInterceptors'; | ||
| import { supabaseLoginWithPassword } from '@services/supabaseAuth'; | ||
|
|
||
| const payloadSchema = Joi.object({ |
There was a problem hiding this comment.
You can define all the schemas in the lib/schemas folder so that they can be reused.
| } | ||
|
|
||
| const { term, limit, offset, country } = request.query; | ||
| console.log(`Searching for songs with term: ${term} and limit: ${limit} offset: ${offset}`); |
There was a problem hiding this comment.
We should not have console logs committed to the code.
| const { authorization: authHeader } = request.headers; | ||
| const match = (authHeader || '').match(/^Bearer\s+(.+)$/i); | ||
| const token = match && match[1]; | ||
|
|
||
| if (!token) { | ||
| throw unauthorized('Access denied. Unauthorized user.'); | ||
| } | ||
|
|
||
| try { | ||
| const user = await getSupabaseUserFromToken({ accessToken: token }); | ||
| request.app.user = user; | ||
| } catch (error) { | ||
| request.log('error', error); | ||
| throw unauthorized('Access denied. Unauthorized user.'); | ||
| } |
There was a problem hiding this comment.
Shouldn't this logic be in a middleware?
| { | ||
| headers: { | ||
| apikey: supabaseConfig.anonKey, | ||
| 'Content-Type': 'application/json', |
There was a problem hiding this comment.
The content type header is repeated multiple times in this file. We can define common headers in constants and just spread them here.
| mysql_data: | ||
|
|
||
|
|
||
| # app: |
There was a problem hiding this comment.
Why have we commented out this part?
There was a problem hiding this comment.
Just to avoid visiting docker every time i get something to debug while working locally.
| buildSupabaseInsertHeaders, | ||
| } from '@utils/supabaseHeaders'; | ||
|
|
||
| const TABLE = 'liked_songs'; |
| const assertSupabaseConfigured = () => { | ||
| if (!supabaseConfig.url || !supabaseConfig.anonKey) { | ||
| throw badImplementation( | ||
| 'Supabase is not configured. Set SUPABASE_URL and SUPABASE_ANON_KEY.', |
There was a problem hiding this comment.
Get such hardcoded strings from constants file
| { | ||
| method: 'GET', | ||
| path: '/', | ||
| options: { |
There was a problem hiding this comment.
Define these options in constants
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
No description provided.