Skip to content

Instantly share code, notes, and snippets.

View mr-pascal's full-sized avatar

Pascal mr-pascal

View GitHub Profile
module app
go 1.17
require (
github.com/go-playground/webhooks/v6 v6.0.0-rc.1
github.com/gofiber/fiber/v2 v2.25.0
github.com/valyala/fasthttp v1.32.0
)
workspace(
name = "my_workspace",
# Bazel should manage the "node_modules" directory
managed_directories = {"@npm": ["node_modules"]},
)
// ...
load("@build_bazel_rules_nodejs//:index.bzl", "npm_install")
npm_install(
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
nodejs_binary(
name = "app",
entry_point = ":index.js",
data = [
# Define needed NPM package dependency
"@npm//express"
]
)
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
console.log('Received request');
res.send('Hello World!')
})
app.listen(port, () => {
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
nodejs_binary(
name = "app",
entry_point = ":index.js"
)
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
nodejs_binary(
name = "app_glob",
entry_point = ":index.js",
## **/*.js -> matches every '.js' file in every subdirectory of this package
data = glob(["**/*.js"])
)
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
nodejs_binary(
name = "app",
entry_point = ":index.js",
## Adding the "subfolder/second.js" file to the "binary"
data = ["subfolder/second.js"]
)
// Import 'second' module
const myModule = require('./subfolder/second');
// Expecting 'Hello Bazel' as output
console.log(myModule.myFunc('Bazel'));
module.exports = {
// Adds 'Hello' in front of the input string and returns it
myFunc: (input) => {
return `Hello ${input}`
}
}
bazel-bin
bazel-medium-bazel-nodejs-getting-started
bazel-out
bazel-testlogs
.idea
node_modules