forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d32d3a8
commit 38c810f
Showing
12 changed files
with
1,094 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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 @@ | ||
import %workspace%/../../common.bazelrc |
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,15 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
exports_files(["tsconfig.json"]) |
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 @@ | ||
# Nest Bazel Example |
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,61 @@ | ||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
workspace( | ||
name = "examples_nestjs", | ||
managed_directories = {"@npm": ["node_modules"]}, | ||
) | ||
|
||
# In your code, you'd fetch this repository with an `http_archive` call. | ||
# We do this local repository only because this example lives in the same | ||
# repository with the rules_nodejs code and we want to test them together. | ||
local_repository( | ||
name = "build_bazel_rules_nodejs", | ||
path = "../../dist/build_bazel_rules_nodejs/release", | ||
) | ||
|
||
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install") | ||
|
||
yarn_install( | ||
name = "npm", | ||
package_json = "//:package.json", | ||
yarn_lock = "//:yarn.lock", | ||
) | ||
|
||
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies") | ||
|
||
install_bazel_dependencies() | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "io_bazel_rules_docker", | ||
sha256 = "87fc6a2b128147a0a3039a2fd0b53cc1f2ed5adb8716f50756544a572999ae9a", | ||
strip_prefix = "rules_docker-0.8.1", | ||
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.8.1.tar.gz"], | ||
) | ||
|
||
load( | ||
"@io_bazel_rules_docker//repositories:repositories.bzl", | ||
container_repositories = "repositories", | ||
) | ||
|
||
container_repositories() | ||
|
||
load( | ||
"@io_bazel_rules_docker//nodejs:image.bzl", | ||
nodejs_image_repositories = "repositories", | ||
) | ||
|
||
nodejs_image_repositories() |
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,19 @@ | ||
{ | ||
"private": true, | ||
"dependencies": { | ||
"@nestjs/common": "6.5.2", | ||
"@nestjs/core": "6.5.2", | ||
"@nestjs/platform-express": "6.5.2", | ||
"minimist": "1.2.0", | ||
"reflect-metadata": "0.1.13", | ||
"rxjs": "6.5.2" | ||
}, | ||
"devDependencies": { | ||
"@bazel/typescript": "file:../../dist/npm_bazel_typescript", | ||
"@types/node": "12.6.3", | ||
"typescript": "3.5.3" | ||
}, | ||
"scripts": { | ||
"test": "bazel build ... && bazel build --platforms=@build_bazel_rules_nodejs//toolchains/node:linux_amd64 ..." | ||
} | ||
} |
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,55 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@npm_bazel_typescript//:index.bzl", "ts_library") | ||
|
||
ts_library( | ||
name = "app", | ||
srcs = glob(["*.ts"]), | ||
deps = [ | ||
"@npm//@nestjs/common", | ||
"@npm//@nestjs/core", | ||
"@npm//@types/node", | ||
"@npm//tslib", | ||
], | ||
) | ||
|
||
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") | ||
|
||
# bazel run //src:server -- --port=4000 | ||
nodejs_binary( | ||
name = "server", | ||
data = [ | ||
":app", | ||
"@npm//@nestjs/common", | ||
"@npm//@nestjs/core", | ||
"@npm//@nestjs/platform-express", | ||
"@npm//minimist", | ||
], | ||
entry_point = ":main.ts", | ||
) | ||
|
||
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image") | ||
|
||
# bazel build --platforms=@build_bazel_rules_nodejs//toolchains/node:linux_amd64 //src:docker | ||
nodejs_image( | ||
name = "docker", | ||
data = [ | ||
":app", | ||
], | ||
entry_point = ":main.ts", | ||
node_modules = "@npm//:node_modules", | ||
) |
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,9 @@ | ||
import {Controller, Get} from '@nestjs/common'; | ||
|
||
@Controller() | ||
export class AppController { | ||
@Get() | ||
getGreeting(): string { | ||
return 'Hello world!'; | ||
} | ||
} |
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,9 @@ | ||
import {Module} from '@nestjs/common'; | ||
import {AppController} from './app.controller'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [AppController], | ||
providers: [], | ||
}) | ||
export class AppModule {} |
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,15 @@ | ||
import {Logger} from '@nestjs/common'; | ||
import {NestFactory} from '@nestjs/core'; | ||
|
||
import {AppModule} from './app.module'; | ||
|
||
async function bootstrap(port: number) { | ||
const app = await NestFactory.create(AppModule); | ||
await app.listen(port); | ||
Logger.log(`Application served at http://localhost:${port}`); | ||
} | ||
|
||
if (require.main === module) { | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
bootstrap(argv.port || 3000); | ||
} |
Empty file.
Oops, something went wrong.