Giter Site home page Giter Site logo

idisposable / cloudfinger Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 1.0 553 KB

A webfinger handler build with CloudFlare Workers and KV Store

License: MIT License

JavaScript 7.03% TypeScript 92.97%
cloudflare cloudflare-worker cloudflare-workers mastodon webfinger

cloudfinger's People

Contributors

dependabot[bot] avatar idisposable avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

huslage

cloudfinger's Issues

Add an API to allow inserting / updating / deleting mappings

Need a simple API that allows for programmatic updating of the mappings. This will initially be used from the command line (e.g. curl, and be secured by the same pre-shared-key AUTH_TOKEN that the current /api/list uses.

How

Add the following operations:

  • /api/get/:from - GET the single mapping from a specific id (e.g. the mapping for [email protected])
  • /api/add - POST a new mapping with both a from and to in the POST body*
  • /api/update/:from - PUT an updated mapping with the new values for both the from and to in the PUT body*
  • /api/delete/:from - DELETE an existing mapping of the specified from value

Notes

POST for the add operation

URI: /api/add - no additional parameters needed

Body:

{
  "from": "[email protected]",
  "to": "@[email protected]"
}

Result:

{
  "success": true,
  "errors": [ ]
}

Note: Will return false with appropriate HTTP Status Code and an explanation in the errors attribute. A 400-Bad Request will be returned if either the from or the to are blank or both have the same value. A 409-Conflict will be returned if the from already has an existing mapping that doesn't match the requested to value. If both the from and to values match a 200-OK response will be returned (as this is likely a repeated request).

PUT for the update operation

URI: /api/update/:from where the from value is the from value of an existing mapping. This allow changing a mapping's from or to value at will. An example would be /api/update/[email protected].

Body:

{
  "from": "[email protected]",
  "to": "@[email protected]"
}

Result:

{
  "success": true
  "errors": [ ]
}

Note: Will return false with appropriate HTTP Status Code and an explanation in the errors attribute. 404-Not Found status code means the URI from value was not in the existing mappings. 409-Conflict status code means the post-body supplied from value already exists but is NOT the value supplied in the URI (e.g. you tried to change [email protected]'s from to [email protected] and that already has a mapping). If the existing mapping matches what was requested in the PUT, a 200-OK status code will be returned (as this is likely a repeated request).

DELETE for the delete operation

URI: /api/delete/:from where the from value is the from value of an existing mapping. An example would be /api/update/[email protected]. There is no DELETE body content

Result:

{
  "success": true
  "errors": [ ]
}

Note: Will return false with appropriate HTTP Status Code and an explanation in the errors attribute. 410 GONE means the URI from value was not in the existing mappings (as this is likely a repeated request).

HTTP Status Codes

Status Code Description List Add Update Delete
200 OK Indicates that the request has succeeded. X X X
201 Created Indicates that the request has succeeded and a new resource has been created as a result. X
204 No Content The server has fulfilled the request but does not need to return a response body. The server may return the updated meta information. X
400 Bad Request The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request without modifications. X X X X
404 Not Found The server can not find the requested resource. X X
409 Conflict The request could not be completed due to a conflict with the current state of the resource. X X
410 Gone The requested resource is no longer available at the server. X X

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.