-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from drashland/issue-#182-create-app-script
Issue #182 create app script
- Loading branch information
Showing
21 changed files
with
714 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
## Table of Contents | ||
- [Quick Start](#quick-start) | ||
- [Create Drash App](#create-drash-app) | ||
- [Documentation](#documentation) | ||
- [Features](#features) | ||
- [Why use Drash?](#why-use-drash) | ||
|
@@ -65,6 +66,26 @@ $ curl localhost:1447 | |
Hello World! deno + Drash is cool! | ||
``` | ||
|
||
## Create Drash App | ||
|
||
Drash provides a basic tool to help you quickly create a Drash skeleton, with everything working out of the box, ready for you to build something great with. | ||
|
||
This tool does not require you to install any Drash scripts or modules. It will create the skeleton of your choice (an API, a full web app, or a full web app with Vue) inside your current working directory. | ||
|
||
To get started with the Create Drash App tool, see the following commands: | ||
|
||
``` | ||
$ mkdir my-drash-project | ||
$ cd my-drash-project | ||
$ deno run --allow-run --allow-read --allow-write https://deno.land/x/[email protected]/create_app.ts [OPTIONS] | ||
``` | ||
|
||
Display the options with `--help`: | ||
|
||
``` | ||
$ deno run --allow-run https://deno.land/x/[email protected]/create_app.ts --help | ||
``` | ||
|
||
## Documentation | ||
|
||
[Full Documentation](https://drash.land/docs) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Drash } from "./deps.ts" | ||
import HomeResource from "./resources/home_resource.ts"; | ||
|
||
const server = new Drash.Http.Server({ | ||
directory: Deno.realPathSync("./"), | ||
response_output: "application/json", | ||
logger: new Drash.CoreLoggers.ConsoleLogger({ | ||
enabled: false, | ||
level: "debug", | ||
}), | ||
resources: [ | ||
HomeResource, | ||
], | ||
}); | ||
|
||
await server.run({ | ||
hostname: "localhost", | ||
port: 1667, | ||
}); | ||
|
||
console.log(`Server listening: http://${server.hostname}:${server.port}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Drash } from "./deps.ts" | ||
import HomeResource from "./resources/home_resource.ts"; | ||
|
||
const server = new Drash.Http.Server({ | ||
directory: Deno.realPathSync("./"), | ||
response_output: "text/html", | ||
logger: new Drash.CoreLoggers.ConsoleLogger({ | ||
enabled: false, | ||
level: "debug", | ||
}), | ||
resources: [ | ||
HomeResource, | ||
], | ||
static_paths: ["/public"], | ||
views_path: "./public/views", | ||
}); | ||
|
||
await server.run({ | ||
hostname: "localhost", | ||
port: 1667, | ||
}); | ||
|
||
console.log(`Server listening: http://${server.hostname}:${server.port}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Drash } from "https://deno.land/x/[email protected]/mod.ts" | ||
export { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "", | ||
"version": "1.0.0", | ||
"description": "", | ||
"scripts": { | ||
"buildVue": "node_modules/.bin/webpack-cli --config webpack.config.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"babel-core": "^7.0.0-bridge.0", | ||
"core-js": "^3.6.4" | ||
}, | ||
"devDependencies": { | ||
"babel-loader": "^8.0.6", | ||
"webpack": "^4.41.5", | ||
"webpack-cli": "^3.3.10", | ||
"vue-loader": "^15.9.2", | ||
"html-webpack-plugin": "^4.3.0", | ||
"vue-template-compiler": "^2.6.11", | ||
"@babel/core": "^7.9.6", | ||
"css-loader": "^3.5.3", | ||
"vue": "^2.6.11", | ||
"vue-style-loader": "^4.1.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
main { | ||
margin: auto; | ||
} | ||
h1 { | ||
color: #282828; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<script src="/public/js/index.js"></script> | ||
<link rel="stylesheet" href="/public/css/index.css"> | ||
<title>Drash - Create App</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>Welcome</h1> | ||
<p>Welcome to your new application, start building something great with Drash!</p> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Drash - Create App</title> | ||
</head> | ||
<body> | ||
<main> | ||
<div id="app"></div> | ||
<script src="/public/js/app.js"></script> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Drash } from "../deps.ts"; | ||
|
||
export default class HomeResource extends Drash.Http.Resource { | ||
static paths = ["/"]; | ||
|
||
public GET() { | ||
this.response.body = this.response.render('/index.html'); | ||
return this.response; | ||
} | ||
|
||
public POST() { | ||
this.response.body = JSON.stringify({ message: "Not implemented" }) | ||
return this.response; | ||
} | ||
|
||
public DELETE() { | ||
this.response.body = JSON.stringify({ message: "Not implemented" }) | ||
return this.response; | ||
} | ||
|
||
public PUT() { | ||
this.response.body = JSON.stringify({ message: "Not implemented" }) | ||
return this.response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Drash } from "../deps.ts"; | ||
|
||
export default class HomeResource extends Drash.Http.Resource { | ||
static paths = ["/"]; | ||
|
||
public GET() { | ||
this.response.body = JSON.stringify({ success: true, message: 'GET request received.' }); | ||
return this.response; | ||
} | ||
|
||
public POST() { | ||
this.response.body = JSON.stringify({ message: "Not implemented" }) | ||
return this.response; | ||
} | ||
|
||
public DELETE() { | ||
this.response.body = JSON.stringify({ message: "Not implemented" }) | ||
return this.response; | ||
} | ||
|
||
public PUT() { | ||
this.response.body = JSON.stringify({ message: "Not implemented" }) | ||
return this.response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Drash } from '../../deps.ts' | ||
import { assertEquals } from "../../deps.ts" | ||
import HomeResource from '../../resources/home_resource.ts'; | ||
|
||
Deno.test({ | ||
name: 'HomeResource - GET /', | ||
async fn(): Promise<void> { | ||
const server = new Drash.Http.Server({ | ||
address: "localhost:1557", | ||
resources: [HomeResource] | ||
}); | ||
await server.run() | ||
const response = await fetch('http://localhost:1557') | ||
assertEquals(response.status, 200) | ||
server.close() | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Vue from 'vue'; | ||
import App from './App.vue'; | ||
|
||
new Vue({ | ||
el: '#app', | ||
render: h => h(App), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div id="app"> | ||
<h1>Welcome</h1> | ||
<p>Welcome to your new application, start building something great with Drash!</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
}; | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss"> | ||
#app { | ||
max-width: 400px; | ||
margin: 0 auto; | ||
line-height: 1.4; | ||
font-family: 'Avenir', Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
color: blue; | ||
} | ||
h1 { | ||
text-align: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const { VueLoaderPlugin } = require('vue-loader') | ||
module.exports = { | ||
entry: { | ||
app: './vue/app.js' | ||
}, | ||
output: { | ||
filename: "[name].js", | ||
path: __dirname + '/public/js/' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.vue$/, | ||
use: [ | ||
{ | ||
loader: 'vue-loader' | ||
} | ||
] | ||
}, | ||
{ | ||
test: /\.js$/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader' | ||
} | ||
] | ||
}, | ||
{ | ||
test: /\.(css|sass|scss)$/, | ||
use: ["vue-style-loader", "css-loader"] | ||
}, | ||
] | ||
}, | ||
resolve: { | ||
extensions: ['.vue', '.js'] | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
template: './public/views/index.html', | ||
}), | ||
new VueLoaderPlugin(), | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.