-
Notifications
You must be signed in to change notification settings - Fork 443
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
Add persist API #1575
Add persist API #1575
Conversation
0e89a47
to
e9920ba
Compare
steps[step - 1]?.(); | ||
}; | ||
} | ||
} |
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.
ideally I would like to have a real in-memory database that can be used in tests. But knex in-memory solution is to use sqlite which doesn't support our schema.
So for now I am just mocking the db queries
e9920ba
to
7cfb5fe
Compare
} else { | ||
next(); | ||
} | ||
}); |
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.
do we want some sort of authorization mechanism to make sure requests are legit and actually made from a runner?
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.
If the persist service is a private service then I don't think that is necessary yet.
1549099
to
bbf9399
Compare
packages/persist/lib/server.ts
Outdated
}), | ||
body: z.object({ | ||
activityLogId: z.number(), | ||
level: z.enum(['info', 'debug', 'error', 'warn', 'http', 'verbose', 'silly']), |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
2da6a86
to
4534a44
Compare
.github/workflows/deploy.yaml
Outdated
docker buildx imagetools create nangohq/nango-persist:${{ github.sha }} --tag nangohq/nango-persist:${{ inputs.stage }} | ||
- name: Deploy persist | ||
run: | | ||
SERVICE_ID=${{ fromJson('{ production: "srv-XXXXXXXXXXXXX", staging: "srv-cmsfiqqcn0vc73bhcod0" }')[inputs.stage] }} |
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.
We have this prod value now right?
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.
yep. let me update it
packages/persist/lib/server.ts
Outdated
export const server = express(); | ||
server.use(express.json()); | ||
|
||
// logging middleware |
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.
can the non helpful comments be removed?
packages/persist/lib/server.ts
Outdated
console.log(`[Persist] ${req.method} ${req.path} ${res.statusCode}`); | ||
}); | ||
|
||
// routes |
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.
^ remove
packages/persist/lib/server.ts
Outdated
); | ||
server.put('/environment/:environmentId/connection/:connectionId/sync/:syncId/job/:syncJobId/records', validateRecordsRequest, persistController.updateRecords); | ||
|
||
// error handling middleware |
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.
^ remove
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.
Looks good. Couple of non blocking comments and the note to add the persist server address in the github action
The goal is to remove the database dependency for the runner. Writing customers data (batchSave/.../activityLogs/lastSyncDate) will go through this API
4534a44
to
e741e5f
Compare
type LogLevel = 'info' | 'debug' | 'error' | 'warn' | 'http' | 'verbose' | 'silly'; | ||
import axios from 'axios'; | ||
import { getPersistAPIUrl } from '../utils/utils.js'; | ||
import type { LogLevel } from '../models/Activity.js'; |
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.
First commit implementing the persist API.
The goal is to remove the database dependency for the runner. Writing customers data (batchSave/.../activityLogs/lastSyncDate) will go through this API
All of it behind a feature flag
Next PR: take care of removing db dependency for proxy.
Issue ticket number and link
https://linear.app/nango/issue/NAN-270/persist-api
Checklist before requesting a review (skip if just adding/editing APIs & templates)