v7.?.? (upcoming)
New Features:
added url typesafety.
a step forward to end-to-end typesafety.
added
doc
command.generate a simple documentation for your api.
added
new
command.create a new app using one of our templates and get up and running in no time!
darkflare new
added
Spotify
andDiscord
oauth2 providers.
v7.2.3
Bug Fixes:
updated import of
FetchContext
in oauth2 module.this bug caused the build process to fail.
v7.2.1
Revisions:
upgraded drgn to
v0.9.0
which should fix some issues.please reinstall darkflare’s cli:
deno run -A -q https://deno.land/x/drgn@v0.9.0/installer.js -n darkflare -u darkflare@$version/cli/mod.ts
added test workflow to ensure greater reliability.
v7.2.0
New Features:
moved
authenticator
,jwt
,encrypt
, anddecrypt
modules to the core.import { authenticator, jwt, encrypt, decrypt } from 'darkflare'
published darkflare/client to npm.
the versioning does not follow the versioning of darkflare.
npm i @darkflare/client
import { Client } from '@darkflare/client' // ~1.5 kB
Bug Fixes:
make sure to clone the incoming request to get a untouched Request object and a untouched readable stream.
this should prevent the error “The stream has already been consumed” from occurring.
- c.req.raw + c.req.raw() - c.req.stream + c.req.stream()
v7.1.2
Revisions:
c.error()
,c.mail()
andc.req.userAgent()
methods are now available onFetchContext
v7.1.1
Revisions:
you can now pass data between hooks using the
c.data
object. you can assign new keys to this object without causing type issues.fixed a type issue that made
decrypt
option in jwt module not optional.
v7.1.0
New Features:
hooks are now available.
hooks are functions that allow you to extend the functionality of a route and reuse functions throughout your app without having to write the same code over and over again.
import { Get } from 'darkflare' Get({ preValidator(c) { ... } }, c => { ... })
Revisions:
we try to make the developer experience as smooth as possible. therefore, we’re going to integrate all modules exported under a different path into the core.
// darkflare/jwt import { jwt } from 'darkflare' jwt.sign() jwt.verify() // darkflare/authenticator import { authenticator } from 'darkflare' // encrypt/decrypt import { encrypt, decrypt } from 'darkflare'
v7.0.1
Revisions:
- update guide and edit description in readme
v7.0.0
Breaking Revisions:
removed
darkflare/s3
module.you should import and configure s3 on your own as this gives you much more flexibility.
encrypt()
/decrypt()
functions now require the secret as a parameter.removed custom error handlers.
the built-in error handler now responds with either json or plain text, based on the
accept
header of the incoming request.darkflare.yml
is now the file to configure darkflare and it’s fully optional to use one.most features require now specific environment variables to be set.
New Features:
cron trigger
you can now add a handler for the
ScheduledEvent
. create acron.ts
file in the root.import { cron } from 'darkflare' cron(c => { ... })
mail trigger
you can now add a handler for the
EmailEvent
. create amail.ts
file in the root.import { mail } from 'darkflare' mail(c => { ... })
DurableObjects
can now be used with darkflare.create a file named
*.object.ts
in the root directory.export class MyDurableObject implements DurableObject { }
Revisions:
darkflare now uses drgn v0.5.2, which comes with automated updates.
you can now have
*.test.ts
/*.d.ts
files within the /api directory.before v7, darkflare threw an error in case the directory contained one of these files. now they get ignored.
v6.4.1
Bug Fixes:
- add missing export of
err
function todarkflare/x
module.
- add missing export of
v6.4.0
Notable Revisions:
you should now configure your app this way.
configure
method is now deprecated and will be removed on the next breaking release.import { Darkflare } from 'https://deno.gg/darkflare@v6.4.0' new Darkflare({ name: 'my app', ... })
plus, your config file should now be named
darkflare.ts
without the dot.any utility functions are now available under
darkflare/x
.this includes:
encrypt()
decrypt()
parseUserAgent()
sendMail()
err()
New Features:
add authentication to your app using the new
oauth2
module.darkflare.ts
import { Darkflare } from 'https://deno.gg/darkflare@v6.4.0' new Darkflare({ oauth2: { github: { client_id: '{id}', client_secret: '{secret}', }, }, })
api/oauth2/github/login.ts
import { Get, v } from 'darkflare' import { Github } from 'darkflare/oauth2' Get({}, async (ctx) => { Github.redirect(ctx, ['read:user', 'user:email']) })
api/oauth2/github/callback.ts
import { Get, v } from 'https://deno.gg/darkflare@v6.4.0' import { Github } from 'https://deno.gg/darkflare@v6.4.0/oauth2' Get({ query: v.object({ code: v.string(), }), }, async ({ req }) => { const token = await Github.getAccessToken(req.query.code), user = await Github.getUser(token) return `Welcome, ${user.name}!` })
Revisions:
deprecated
passThroughOnException
option.since darkflare is a API engine, it should never happen that you have to forward the request to an origin server, should an exception occur, since there cannot be an origin server on the same route/domain that darkflare is running on.
v6.3.1
Revisions:
- patched dependencies.
v6.3.0
New Features:
easier error handling with the
err
function.import { err, Get } from 'darkflare' Get({}, (ctx) => { if (!ctx.req.headers.authentication) { return err('UNAUTHORIZED') // or: err(403) } return 'Welcome back!' })
{ "code": 403, "message": "Unauthorized" }
v6.2.1
Bug Fixes:
- undo recent addition of
env
export.
- undo recent addition of
v6.2.0
New Features:
access your environment variables completely stateless.
import { env } from 'https://deno.gg/darkflare@v6.2.0' export function func() { console.log(env) }
Bug Fixes:
no more usage of built-in Deno functions.
https://esm.sh/file-type@18.2.0
seemed to cause some unexpected imports.
v6.1.0
New Features:
exp
andnbf
options in jwt’ssign
method now automatically determine the seconds elapsed since midnight, January 1, 1970 UTC.
v6.0.1
Bug Fixes:
- cli should now work as expected
v6.0.0
Breaking Revisions:
removed
Store
utilitywe recommend to use e.g. flare as an alternative.
removed
Webhook
utilityyou should know how to send a webhook. so this utility is pretty useless.
renamed
deploycommand to publishindex routes must now be named
mod.ts
(following Deno’s naming convention)jwt module now uses djwt under the hood
the module exports only two methods now:
sign
(create a new token) andverify
(validate tokens and return payload if it’s valid)
Bug Fixes:
realm-web
is only included in the bundle if you’re actually using it
New Features:
added
darkflare/authenticator
modulea easy and well-tested module for creating and validating one time passwords.
added
encrypt
anddecrypt
functionsencrypt/decrypt text using AES-GCM SHA-256.