Skip to content

Commit 205b347

Browse files
first commit
0 parents  commit 205b347

File tree

14 files changed

+445
-0
lines changed

14 files changed

+445
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

examples/compiler.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Codegyan } from '../src/Codegyan';
2+
3+
// Initialize the Codegyan with your API key and client ID
4+
const client = new Codegyan('YOUR_API_KEY', 'YOUR_CLIENT_ID');
5+
6+
async function main() {
7+
// Example usage of the CompilerApiClient to compile code
8+
9+
// Example JavaScript code to compile
10+
const lang = 'python';
11+
const code = 'print("Hello, World!")';
12+
13+
// Call the compile method of the CompilerApiClient with JavaScript as the language
14+
client.compilerApiClient.compile(lang, code)
15+
.then(result => {
16+
// Log the compilation result
17+
console.log(result.data);
18+
})
19+
.catch(error => {
20+
// Handle any errors
21+
console.error('Error:', error);
22+
});
23+
}
24+
25+
main();

examples/currency.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Codegyan } from '../src/Codegyan';
2+
3+
// Initialize the Codegyan with your API key and client ID
4+
const client = new Codegyan('YOUR_API_KEY', 'YOUR_CLIENT_ID');
5+
6+
async function main() {
7+
// Example usage of the toolsApiClient to currency conversion
8+
9+
// Example JavaScript code to compile
10+
const from_currency = 'USD';
11+
const to_currency = 'INR';
12+
const amount = '100';
13+
14+
// Call the compile method of the CompilerApiClient with JavaScript as the language
15+
client.toolsApiClient.currency(from_currency, to_currency, amount)
16+
.then(result => {
17+
// Log the compilation result
18+
console.log(result.data);
19+
})
20+
.catch(error => {
21+
// Handle any errors
22+
console.error('Error:', error);
23+
});
24+
}
25+
26+
main();

examples/domain.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Codegyan } from '../src/Codegyan';
2+
3+
// Initialize the Codegyan with your API key and client ID
4+
const client = new Codegyan('YOUR_API_KEY', 'YOUR_CLIENT_ID');
5+
6+
async function main() {
7+
// Example usage of the toolsApiClient to check domain availability
8+
9+
// Example JavaScript code to compile
10+
const domain = 'codegyan.in';
11+
12+
// Call the compile method of the CompilerApiClient with JavaScript as the language
13+
client.toolsApiClient.domainAvailability(domain)
14+
.then(result => {
15+
// Log the compilation result
16+
console.log(result.data);
17+
})
18+
.catch(error => {
19+
// Handle any errors
20+
console.error('Error:', error);
21+
});
22+
}
23+
24+
main();

package-lock.json

Lines changed: 138 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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "codegyan",
3+
"version": "0.1.0",
4+
"description": "The official TypeScript library for the Codegyan API",
5+
"author": "Codegyan <support@codegyan.in>",
6+
"types": "dist/src/index.d.ts",
7+
"main": "dist/src/index.js",
8+
"type": "commonjs",
9+
"repository": "github:codegyan-llc/codegyan-node",
10+
"license": "Apache-2.0",
11+
"packageManager": "yarn@1.22.22",
12+
13+
"files": [
14+
"*"
15+
],
16+
"private": false,
17+
"scripts": {
18+
"build": "tsc --build",
19+
"prepare": "npm run build",
20+
"clean": "tsc --build --clean"
21+
},
22+
"dependencies": {
23+
"@types/node": "^18.11.18",
24+
"@types/node-fetch": "^2.6.4",
25+
"formdata-node": "^4.3.2",
26+
"node-fetch": "^2.6.7"
27+
},
28+
"devDependencies": {
29+
"@swc/core": "^1.3.102",
30+
"@swc/jest": "^0.2.29",
31+
"@types/jest": "^29.4.0",
32+
"@typescript-eslint/eslint-plugin": "^6.7.0",
33+
"@typescript-eslint/parser": "^6.7.0",
34+
"eslint": "^8.49.0",
35+
"eslint-plugin-prettier": "^5.0.1",
36+
"eslint-plugin-unused-imports": "^3.0.0",
37+
"jest": "^29.4.0",
38+
"prettier": "^3.0.0",
39+
"ts-jest": "^29.1.0",
40+
"ts-morph": "^19.0.0",
41+
"ts-node": "^10.5.0",
42+
"tsc-multi": "^1.1.0",
43+
"tsconfig-paths": "^4.0.0",
44+
"typescript": "^4.8.2"
45+
}
46+
}

src/.DS_Store

6 KB
Binary file not shown.

src/Codegyan.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { ToolsApiClient } from "./response/ToolsApiClient";
2+
import { CompilerApiClient } from "./response/CompilerApiClient";
3+
4+
/**
5+
* Main client for interacting with Codegyan API.
6+
*
7+
* This class provides access to various API clients such as ToolsApiClient and CompilerApiClient,
8+
* which can be used to perform various operations supported by the Codegyan API.
9+
*/
10+
export class Codegyan {
11+
/**
12+
* An instance of ToolsApiClient used to interact with the tools-related endpoints of the Codegyan API.
13+
*/
14+
public toolsApiClient: ToolsApiClient;
15+
16+
/**
17+
* An instance of CompilerApiClient used to interact with the compiler-related endpoints of the Codegyan API.
18+
*/
19+
public compilerApiClient: CompilerApiClient;
20+
21+
/**
22+
* Initializes the Codegyan client with the provided API key and client ID.
23+
*
24+
* @param apiKey - The API key for authentication. This key is required to authorize requests to the Codegyan API.
25+
* @param clientId - The client ID for authentication. This ID is used to identify the client making the requests.
26+
*/
27+
constructor(apiKey: string, clientId: string) {
28+
/**
29+
* Initializes the ToolsApiClient with the provided API key and client ID.
30+
* This client will be used to interact with the tools-related endpoints of the Codegyan API.
31+
*/
32+
this.toolsApiClient = new ToolsApiClient(apiKey, clientId);
33+
34+
/**
35+
* Initializes the CompilerApiClient with the provided API key and client ID.
36+
* This client will be used to interact with the compiler-related endpoints of the Codegyan API.
37+
*/
38+
this.compilerApiClient = new CompilerApiClient(apiKey, clientId);
39+
}
40+
}

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { Codegyan } from "./Codegyan";
2+
export * from "./response/ToolsApiClient";
3+
export * from "./response/CompilerApiClient";
4+
export * from "./models";

0 commit comments

Comments
 (0)