A microframework for building JavaScript HTTP applications. Runtime-agnostic. Strongly typed.
GPL-3.0 License
Bot releases are hidden (Show)
Published by crookse over 5 years ago
Imported modules referenced master branches. They now reference specific versions.
Drash.Http.Request
uses:
import { ServerRequest } from "https://raw.githubusercontent.com/denoland/deno_std/v0.3.4/http/server.ts";
Drash.Http.Server
uses:
import { serve } from "https://raw.githubusercontent.com/denoland/deno_std/v0.3.4/http/server.ts";
Drash.Dictionaries.MimeDb
references https://raw.githubusercontent.com/jshttp/mime-db/v1.39.0/db.json
Published by crookse over 5 years ago
Fix issue with Drash.Http.Response.send()
method. It didn't need async/await
.
Published by crookse over 5 years ago
Drash.Http.Response.send()
is now async
. This method now calls await this.generateResponse()
. Reason is because the generate methods can be overridden and converted to async
methods and send()
would need to use await
in those cases without having to be overridden as well.
Published by crookse over 5 years ago
Fixed issue with methods converted to public methods in previous release. Methods in previous release need to return any
so that they can be completely overridden.
Published by crookse over 5 years ago
The methods that generate the response based on content type are now public:
Drash.Http.Response.generateHtmlResponse()
Drash.Http.Response.generateJsonResponse()
Drash.Http.Response.generateXmlResponse()
See https://crookse.github.io/deno-drash/#/api-reference/http/response for docs page.
Published by crookse over 5 years ago
Published by crookse over 5 years ago
The following classes couldn't be overwritten after turning Drash into a true namespace:
Drash.Http.Response
Drash.Http.Request
These classes can be overwritten now.
Published by crookse over 5 years ago
Drash
is now defined using the namespace
keyword: https://github.com/crookse/deno-drash/blob/master/mod.ts
All members should have been exported without breaking changes (as seen by the tests).
Docs are updated: https://crookse.github.io/deno-drash/#/
Published by crookse over 5 years ago
Published by crookse over 5 years ago
Fixed issue with static files not being served properly. The test directory was hard-coded into Drash.Http.Response
. To properly serve static files, set the following env var:
DRASH_SERVER_DIRECTORY
Example:
#!/bin/bash
export DRASH_SERVER_DIRECTORY="/path/that/contains/your/app.ts/file"
Notes
DRASH_SERVER_DIRECTORY
because your app.ts
file is essentially a Drash server that starts up a Deno server.Published by crookse over 5 years ago
Fixed generateHtmlResponse()
in Drash.Http.Response
. Users weren't able to generate their own custom HTML unless they were overriding Drash.Http.Response
. This is no longer true. Users can now set a full HTML document (as a string) in this.response.body
in a resource class and it will generate whatever was provided.
Published by crookse over 5 years ago
Published by crookse over 5 years ago
What's New
Drash.Dictionaries.MimeDb
- A dictionary of the db.json
file at https://github.com/jshttp/mime-db. This is used in Drash.Services.HttpService.getMimeType()
to get the MIME type of a file using the file's name or a URL to a file.
Drash.Vendor
- A namespace to store third party code using Drash.addMember(name, member)
.
Drash.addMember(name, member)
- Add a new member to the Drash.Vendor
namespace. This member can be accessed throughout your entire Drash project as long as you import
Drash in the file that expects to use a Drash.Vendor
member. This member can be anything you want it to be. Example below
// app.ts
import Drash from "https://deno.land/x/drash/mod.ts";
class SomeClassName {
public sayHello() {
return "Hello!";
}
}
Drash.addMember("Greeter", SomeClassName);
// some_file.ts
import Drash from "https://deno.land/x/drash/mod.ts";
let greeter = new Drash.Vendor.Greeter();
console.log(greeter.sayHello());
Drash.Http.Server
object:import Drash from "https://deno.land/x/drash/mod.ts";
import IndexResource from "./src/index_resource.ts";
let server = new Drash.Http.Server({
address: "localhost:8000",
response_output: "text/html",
resources: [IndexResource],
static_paths: ["/public"]
});
server.run();
Drash.Http.Response.sendStatic()
- Handles sending respones for static files.
Drash.Services.HttpService.getMimeType(file, fileIsUrl)
for getting the MIME type of a file or URL:
import Drash from "https://deno.land/x/drash/mod.ts";
Drash.Services.HttpService.getMimeType("some/path/file.js?some=param", true);
// returns "application/javascript"
Drash.Services.HttpService.getMimeType("some/path/file.json", true);
// returns "application/json"
Drash.Services.HttpService.getMimeType("file.css");
// returns "text/css"
Published by crookse over 5 years ago
What's New
.travis.yml
Drash.Dictionaries.LogLevels
Drash.Loggers.Logger
debug(message)
: Log debug messages.error(message)
: Log error messages.fatal(message)
: Log fatal messages.info(message)
: Log info messages.trace(message)
: Log trace messages.warn(message)
: Log warning messages.Drash.Loggers.ConsoleLogger
Drash.Loggers.Logger
and makes its type Logger.TYPE_CONSOLE
so that it's messages are written to the console. The FileLogger
class is coming soon.Drash.Services.HttpService
hydrateHttpRequest(request)
: Hydrate the request with data that is useful for the Drash.Http.Server class
.getHttpRequestUrlQueryParams(request)
: Get the request's query params by parsing its URL.Fixes
Drash.Http.Server
were being used by other servers when they shouldn't have been. These properties are now gone and part of the configs so multiple servers can be created without fear of a cached static property.Published by crookse over 5 years ago
What's New
Drash.Util.FileCreator.httpResources(pathToResources: string)
to create the .drash_http_resources.ts
file. This file contains an import
/export
list of all of your resources.
The contents of the .drash_http_resources.ts
file will look similar to:
import users_resource from "/path/to/your/resources/users_resource.ts";
import home_resource from "/path/to/your/resources/home_resource.ts";
export default [
users_resource,
home_resource,
]
Use like so:
.drash_setup.ts
(or whatever filename you want to use).import Drash from "https://raw.githubusercontent.com/crookse/deno-drash/master/mod.ts";
Drash.Util.FileCreator.httpResources("/path/to/your/resources");
app.ts
(or whatever filename you want to use).import Drash from "https://raw.githubusercontent.com/crookse/deno-drash/master/mod.ts";
import resources from "/path/to/your/resources/.drash_http_resources.ts";
let server = new Drash.Http.Server({
address: "localhost:8000",
response_output: "application/json",
resources: resources
});
server.run()
$ deno .drash_setup.ts
$ deno app.ts --allow-net
Published by crookse over 5 years ago
Fixes
Drash.Http.Response
and Drash.Http.Resource
can now be overridden properly.Published by crookse over 5 years ago
What's New
deno --allow-run --allow-write https://deno.land/x/std/prettier/main.ts
. Thanks prettier
author(s)!Published by crookse over 5 years ago
What's New
Drash.Exceptions.HttpException
class. This class takes (code: number, message?: string)
as its arguments. When Drash.Http.Server
handles an HttpException
, it uses the HttpException
's code to as the response's status code.Published by crookse over 5 years ago
What's New
address
config. Example:
import Drash from './drash/mod.ts';
import HomeResource from "./resources/home_resource.ts";
let server = new Drash.Http.Server({
address: 'localhost:8000',
response_output: 'application/json',
resources: [
HomeResource
]
});
server.run();
Published by crookse over 5 years ago
Initial release