-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mds-agency] Removing version param from agency payload to conform with general v… #331
Conversation
…ersioninig policy.
@@ -471,8 +460,7 @@ export const readStop = async (req: AgencyApiRequest, res: AgencyReadStopRespons | |||
if (!recorded_stop) { | |||
return res.status(404).send({ error: new NotFoundError('Stop not found') }) | |||
} | |||
const { version } = res.locals | |||
res.status(200).send({ version, ...recorded_stop }) | |||
res.status(200).send({ ...recorded_stop }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.send({ ...recorded_stop })
could just be .send(recorded_stop)
return res.status(201).send({ | ||
version | ||
}) | ||
return res.status(201).send({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does res.sendStatus(201)
work or does res.status(201).send({})
result in different content type headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sends a different header. It takes out the charset: utf-8
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits, but LGTM
@@ -31,7 +31,7 @@ export type ApiQuery<Q1 extends string, Q2 extends string[] = never> = { | |||
|
|||
export interface ApiResponse<L = unknown, B = unknown> | |||
extends express.Response< | |||
B | { error: unknown; error_description?: string; error_details?: string[] } | { errors: unknown[] } | {} | |||
B | { error: unknown; error_description?: string; error_details?: string[] } | { errors: unknown[] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to make this it's own interface
interface ApiErrorReponse {
error: unknown
error_description?: string
error_details?: string[]
}
And make the AprResponse <B | ApiErrorResponse | { errors: ApiErrorReponse[] }
@@ -149,8 +147,7 @@ export const getVehiclesByProvider = async (req: AgencyApiRequest, res: AgencyGe | |||
|
|||
try { | |||
const response = await getVehicles(skip, take, url, req.query, provider_id) | |||
const { version } = res.locals | |||
return res.status(200).send({ version, ...response }) | |||
return res.status(200).send({ ...response }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not sure the new object syntax is required in all of these places { ...response }
and response
being equivalent and all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the difference between { response: {...}}
and { "vehicles": [ ... ] "links": { "first": "https://...", "last": "https://...", "prev": "https://...", "next": "https://..." }}
, and the former is not in the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no difference between .send({...response})
and .send(response)
... note that I didn't suggest .send({ response })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Michael, .send({ ...response })
and .send(response)
are the same AFAIK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind. never mind.
packages/mds-agency/types.ts
Outdated
@@ -11,8 +11,7 @@ export type AgencyApiRequest<P extends Params = ParamsDictionary> = ApiRequest<P | |||
|
|||
export type AgencyApiAccessTokenScopes = 'admin:all' | 'vehicles:read' | |||
|
|||
export type AgencyApiResponse<TBody = any> = ApiVersionedResponse< | |||
AGENCY_API_SUPPORTED_VERSION, | |||
export type AgencyApiResponse<TBody = any> = ApiResponse< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the = any
(and thus the eslint warning) since a type is always specified below. Also, unknown
is preferable to any
for don't care scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, could be good to get rid of the spreads if we can.
…ersioninig policy.
PR Checklist
[mds-db] Add PG env var
,[config] Fix eslint config
Impacts