Skip to content

Commit e34e4bf

Browse files
committed
Init node.js project
1 parent b2871b6 commit e34e4bf

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# GitHub RAG Examples
2+
3+
A Node.js project that demonstrates running TypeScript files natively without transpilation using Node.js v22.15.0+ and the experimental type stripping feature.
4+
5+
## Prerequisites
6+
7+
- Node.js v22.15.0 or higher
8+
- npm (comes with Node.js)
9+
10+
## Setup
11+
12+
1. Clone this repository:
13+
```bash
14+
git clone https://github.com/codenote-net/github-rag-examples.git
15+
cd github-rag-examples
16+
```
17+
18+
2. Install dependencies:
19+
```bash
20+
npm install
21+
```
22+
23+
## Running TypeScript Natively
24+
25+
This project is configured to run TypeScript files directly with Node.js without the need for transpilation, using the `--experimental-strip-types` flag.
26+
27+
### Basic TypeScript Example
28+
29+
Run the basic example:
30+
31+
```bash
32+
npm start
33+
```
34+
35+
This executes the `src/index.ts` file directly using Node.js.
36+
37+
## GitHub Repository Clone Script
38+
39+
This project includes a script to clone a GitHub repository using a GitHub App installation token. The script uses the x-access-token authentication method as described in the [GitHub documentation](https://docs.github.com/ja/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation).
40+
41+
### Usage
42+
43+
1. Set the required environment variables:
44+
45+
```bash
46+
export GITHUB_TOKEN="your_github_app_installation_token"
47+
export REPO_OWNER="repository_owner"
48+
export REPO_NAME="repository_name"
49+
export CLONE_DIR="./cloned-repo" # Optional, defaults to './cloned-repo'
50+
```
51+
52+
2. Run the clone script:
53+
54+
```bash
55+
npm run clone
56+
```
57+
58+
This will clone the specified repository using the GitHub App installation token with the specified branch or tag.
59+
60+
## How It Works
61+
62+
Starting with Node.js v22.6.0, Node.js has experimental support for TypeScript syntax through "type stripping". This allows you to run valid TypeScript code directly in Node.js without the need to transpile it first.
63+
64+
From Node.js v23.6.0 onwards, type stripping is enabled by default, but this project explicitly uses the flag for compatibility with Node.js v22.x.
65+
66+
## Project Structure
67+
68+
- `/src` - TypeScript source files
69+
- `package.json` - Project configuration

package-lock.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "github-rag-examples",
3+
"version": "1.0.0",
4+
"description": "GitHub RAG (Retrieval Augmented Generation) examples using Node.js",
5+
"main": "src/index.ts",
6+
"scripts": {
7+
"start": "node --experimental-strip-types src/index.ts",
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"dev": "node --experimental-strip-types --watch src/index.ts"
10+
},
11+
"keywords": [
12+
"github",
13+
"rag",
14+
"node",
15+
"typescript"
16+
],
17+
"author": "Tadashi Shigeoka",
18+
"license": "MIT",
19+
"engines": {
20+
"node": ">=22.15.0"
21+
},
22+
"devDependencies": {
23+
"@types/node": "22.15.0"
24+
}
25+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Hello github-rag-examples");

0 commit comments

Comments
 (0)