|
|
@@ -122,6 +122,68 @@ export namespace Server {
|
|
|
}),
|
|
|
)
|
|
|
.route("/global", GlobalRoutes())
|
|
|
+ .put(
|
|
|
+ "/auth/:providerID",
|
|
|
+ describeRoute({
|
|
|
+ summary: "Set auth credentials",
|
|
|
+ description: "Set authentication credentials",
|
|
|
+ operationId: "auth.set",
|
|
|
+ responses: {
|
|
|
+ 200: {
|
|
|
+ description: "Successfully set authentication credentials",
|
|
|
+ content: {
|
|
|
+ "application/json": {
|
|
|
+ schema: resolver(z.boolean()),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ...errors(400),
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ validator(
|
|
|
+ "param",
|
|
|
+ z.object({
|
|
|
+ providerID: z.string(),
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ validator("json", Auth.Info),
|
|
|
+ async (c) => {
|
|
|
+ const providerID = c.req.valid("param").providerID
|
|
|
+ const info = c.req.valid("json")
|
|
|
+ await Auth.set(providerID, info)
|
|
|
+ return c.json(true)
|
|
|
+ },
|
|
|
+ )
|
|
|
+ .delete(
|
|
|
+ "/auth/:providerID",
|
|
|
+ describeRoute({
|
|
|
+ summary: "Remove auth credentials",
|
|
|
+ description: "Remove authentication credentials",
|
|
|
+ operationId: "auth.remove",
|
|
|
+ responses: {
|
|
|
+ 200: {
|
|
|
+ description: "Successfully removed authentication credentials",
|
|
|
+ content: {
|
|
|
+ "application/json": {
|
|
|
+ schema: resolver(z.boolean()),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ...errors(400),
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ validator(
|
|
|
+ "param",
|
|
|
+ z.object({
|
|
|
+ providerID: z.string(),
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ async (c) => {
|
|
|
+ const providerID = c.req.valid("param").providerID
|
|
|
+ await Auth.remove(providerID)
|
|
|
+ return c.json(true)
|
|
|
+ },
|
|
|
+ )
|
|
|
.use(async (c, next) => {
|
|
|
let directory = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd()
|
|
|
try {
|
|
|
@@ -409,68 +471,6 @@ export namespace Server {
|
|
|
return c.json(await Format.status())
|
|
|
},
|
|
|
)
|
|
|
- .put(
|
|
|
- "/auth/:providerID",
|
|
|
- describeRoute({
|
|
|
- summary: "Set auth credentials",
|
|
|
- description: "Set authentication credentials",
|
|
|
- operationId: "auth.set",
|
|
|
- responses: {
|
|
|
- 200: {
|
|
|
- description: "Successfully set authentication credentials",
|
|
|
- content: {
|
|
|
- "application/json": {
|
|
|
- schema: resolver(z.boolean()),
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- ...errors(400),
|
|
|
- },
|
|
|
- }),
|
|
|
- validator(
|
|
|
- "param",
|
|
|
- z.object({
|
|
|
- providerID: z.string(),
|
|
|
- }),
|
|
|
- ),
|
|
|
- validator("json", Auth.Info),
|
|
|
- async (c) => {
|
|
|
- const providerID = c.req.valid("param").providerID
|
|
|
- const info = c.req.valid("json")
|
|
|
- await Auth.set(providerID, info)
|
|
|
- return c.json(true)
|
|
|
- },
|
|
|
- )
|
|
|
- .delete(
|
|
|
- "/auth/:providerID",
|
|
|
- describeRoute({
|
|
|
- summary: "Remove auth credentials",
|
|
|
- description: "Remove authentication credentials",
|
|
|
- operationId: "auth.remove",
|
|
|
- responses: {
|
|
|
- 200: {
|
|
|
- description: "Successfully removed authentication credentials",
|
|
|
- content: {
|
|
|
- "application/json": {
|
|
|
- schema: resolver(z.boolean()),
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- ...errors(400),
|
|
|
- },
|
|
|
- }),
|
|
|
- validator(
|
|
|
- "param",
|
|
|
- z.object({
|
|
|
- providerID: z.string(),
|
|
|
- }),
|
|
|
- ),
|
|
|
- async (c) => {
|
|
|
- const providerID = c.req.valid("param").providerID
|
|
|
- await Auth.remove(providerID)
|
|
|
- return c.json(true)
|
|
|
- },
|
|
|
- )
|
|
|
.get(
|
|
|
"/event",
|
|
|
describeRoute({
|