mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-11 17:44:21 +01:00
Add OAuth controller
This commit is contained in:
22
src/api/oauth.ts
Normal file
22
src/api/oauth.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { validator, z } from '@/deps.ts';
|
||||
|
||||
const createTokenSchema = z.object({
|
||||
password: z.string(),
|
||||
});
|
||||
|
||||
const createTokenController = validator('json', (value, c) => {
|
||||
const result = createTokenSchema.safeParse(value);
|
||||
|
||||
if (result.success) {
|
||||
return c.json({
|
||||
access_token: result.data.password,
|
||||
token_type: 'Bearer',
|
||||
scope: 'read write follow push',
|
||||
created_at: Math.floor(new Date().getTime() / 1000),
|
||||
});
|
||||
} else {
|
||||
return c.json({ error: 'Invalid request' }, 400);
|
||||
}
|
||||
});
|
||||
|
||||
export { createTokenController };
|
||||
Reference in New Issue
Block a user