drash

A microframework for building JavaScript HTTP applications. Runtime-agnostic. Strongly typed.

GPL-3.0 License

Downloads
119
Stars
1.1K
Committers
20

Bot releases are visible (Hide)

drash - v0.8.3

Published by crookse over 5 years ago

Fixed doc block parsing.

See #62 for more details. Issue fixed by #63.

Added Drash.Util.Exports documentation. See https://crookse.github.io/deno-drash/#/api-reference/util/exports.

drash - v0.8.2

Published by crookse over 5 years ago

Resource classes now have hook_beforeRequest() and hook_afterRequest().

Tutorials added:

drash - v0.8.1

Published by crookse over 5 years ago

Fixed issue with Drash.Http.Server.logger not being accessible from resource class. Drash.Http.Server.logger is now public.

See issue #57 for fix.

drash - v0.8.0

Published by crookse over 5 years ago

TLDR

Resource classes now have access to this.request.body_parsed (as well as other members that have access to the request object) for the request object's body variables.


  • Added Drash.Http.Request.parseBody(). This is called in Drash.Http.Server.handleHttpRequest().
  • If the request's Content-Type header is not set (when a request body is sent), then Drash.Http.Request.parseBody() will try to parse the body as application/json. If it can't parse the body as application/json, then it will try to parse the body as application/x-www-form-urlencoded. The supported Content-Types for Drash.Http.Request.parseBody() are:
    • application/json
    • application/x-www-form-urlencoded
  • Drash.Http.Request.parseBody() sets Drash.Http.Request.body_parsed to false if it can't parse the body.
  • See the method's details here: https://github.com/crookse/deno-drash/blob/master/src/http/request.ts#L138
drash - v0.7.9

Published by crookse over 5 years ago

Drash.Http.Response.send() now supports async overrides.

See #48 for more information. Thanks @liangchunn for finding this.

drash - v0.7.8

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

drash - v0.7.7

Published by crookse over 5 years ago

Fix issue with Drash.Http.Response.send() method. It didn't need async/await.

drash - v0.7.6

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.

drash - v0.7.5

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.

drash - v0.7.4

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.

drash - v0.7.3

Published by crookse over 5 years ago

drash - v0.7.2

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.

drash - v0.7.1

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/#/

drash - v0.7.0

Published by crookse over 5 years ago

drash - v0.6.2

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

  • Do NOT add a trailing slash
  • The env var is named DRASH_SERVER_DIRECTORY because your app.ts file is essentially a Drash server that starts up a Deno server.
drash - v0.6.1

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.

drash - v0.6.0

Published by crookse over 5 years ago

drash - v0.5.0

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());
  • Serve static files by specifying the root path to the static files directory when creating the 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"

drash - v0.4.0

Published by crookse over 5 years ago

What's New

  • .travis.yml
  • Unit tests. Most of the code is covered. Coveralls will be implemented soon.
  • Drash.Dictionaries.LogLevels
    • Contains a list of log levels and their ranks
  • 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
    • Inherits 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

  • Fixed issue where static properties on the 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.
  • Fixed type definitions
  • Fixed issue where URL query params weren't being added (thanks unit tests... seriously... unit tests are important)
drash - v0.3.0

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:

      1. Create .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");
      
      1. Create 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()
      
      1. Run the setup file and your app.
      $ deno .drash_setup.ts
      $ deno app.ts --allow-net
      
Package Rankings
Top 1.1% on Deno.land
Top 24.17% on Npmjs.org
Badges
Extracted from project README
Drash Land Discord