mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat(core): enable creating a new connector with specified id (#3099)
This commit is contained in:
parent
af272446d9
commit
84bb5b29f0
1 changed files with 10 additions and 8 deletions
|
@ -128,16 +128,18 @@ export default function connectorRoutes<T extends AuthedRouter>(
|
|||
router.post(
|
||||
'/connectors',
|
||||
koaGuard({
|
||||
body: Connectors.createGuard.pick({
|
||||
body: Connectors.createGuard
|
||||
.pick({
|
||||
config: true,
|
||||
connectorId: true,
|
||||
metadata: true,
|
||||
syncProfile: true,
|
||||
}),
|
||||
})
|
||||
.merge(Connectors.createGuard.pick({ id: true }).partial()), // `id` is optional
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
const {
|
||||
body: { connectorId, metadata, config, syncProfile },
|
||||
body: { id: proposedId, connectorId, metadata, config, syncProfile },
|
||||
} = ctx.guard;
|
||||
|
||||
const connectorFactories = await loadConnectorFactories();
|
||||
|
@ -190,7 +192,7 @@ export default function connectorRoutes<T extends AuthedRouter>(
|
|||
validateConfig(config, rawConnector.configGuard);
|
||||
}
|
||||
|
||||
const insertConnectorId = generateConnectorId();
|
||||
const insertConnectorId = proposedId ?? generateConnectorId();
|
||||
await insertConnector({
|
||||
id: insertConnectorId,
|
||||
connectorId,
|
||||
|
|
Loading…
Reference in a new issue