From 4e236fda16785076c125e9aa59769a9c71227bec Mon Sep 17 00:00:00 2001 From: tarek Date: Mon, 10 Jul 2023 23:48:38 +0300 Subject: [PATCH] V1.0.3 --- examples/hello-world-app/src/db.d.ts | 6 ++++++ examples/hello-world-app/src/db.js | 14 ++++++++++++++ examples/hello-world-app/src/diInit.d.ts | 1 + examples/hello-world-app/src/diInit.js | 10 ++++++++++ .../hello-world-app/src/getUser.repository.d.ts | 7 +++++++ examples/hello-world-app/src/getUser.repository.js | 9 +++++++++ examples/hello-world-app/src/index.d.ts | 1 + examples/hello-world-app/src/index.js | 6 ++++++ package.json | 4 ++-- tsconfig.json | 3 ++- 10 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 examples/hello-world-app/src/db.d.ts create mode 100644 examples/hello-world-app/src/db.js create mode 100644 examples/hello-world-app/src/diInit.d.ts create mode 100644 examples/hello-world-app/src/diInit.js create mode 100644 examples/hello-world-app/src/getUser.repository.d.ts create mode 100644 examples/hello-world-app/src/getUser.repository.js create mode 100644 examples/hello-world-app/src/index.d.ts create mode 100644 examples/hello-world-app/src/index.js diff --git a/examples/hello-world-app/src/db.d.ts b/examples/hello-world-app/src/db.d.ts new file mode 100644 index 0000000..408c33d --- /dev/null +++ b/examples/hello-world-app/src/db.d.ts @@ -0,0 +1,6 @@ +export declare class DB { + users: { + username: string; + }[]; +} +export declare const db: DB; diff --git a/examples/hello-world-app/src/db.js b/examples/hello-world-app/src/db.js new file mode 100644 index 0000000..4147e6e --- /dev/null +++ b/examples/hello-world-app/src/db.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.db = exports.DB = void 0; +class DB { + constructor() { + this.users = [ + { + username: "tarek", + } + ]; + } +} +exports.DB = DB; +exports.db = new DB(); diff --git a/examples/hello-world-app/src/diInit.d.ts b/examples/hello-world-app/src/diInit.d.ts new file mode 100644 index 0000000..68ee0e6 --- /dev/null +++ b/examples/hello-world-app/src/diInit.d.ts @@ -0,0 +1 @@ +export declare const DiInit: () => void; diff --git a/examples/hello-world-app/src/diInit.js b/examples/hello-world-app/src/diInit.js new file mode 100644 index 0000000..d0427f3 --- /dev/null +++ b/examples/hello-world-app/src/diInit.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DiInit = void 0; +const injectx_1 = require("injectx"); +const db_1 = require("./db"); +const getUser_repository_1 = require("./getUser.repository"); +const DiInit = () => { + (0, injectx_1.GetContainer)('default').Bind(db_1.db, { name: 'db' }).Bind(getUser_repository_1.GetUserRepository); +}; +exports.DiInit = DiInit; diff --git a/examples/hello-world-app/src/getUser.repository.d.ts b/examples/hello-world-app/src/getUser.repository.d.ts new file mode 100644 index 0000000..efa0898 --- /dev/null +++ b/examples/hello-world-app/src/getUser.repository.d.ts @@ -0,0 +1,7 @@ +import { DB } from './db'; +export declare const GetUserRepository: ({ db }: { + db: DB; +}) => (username: string) => { + username: string; +}; +export declare const getUserReposistory: any; diff --git a/examples/hello-world-app/src/getUser.repository.js b/examples/hello-world-app/src/getUser.repository.js new file mode 100644 index 0000000..b20786c --- /dev/null +++ b/examples/hello-world-app/src/getUser.repository.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getUserReposistory = exports.GetUserRepository = void 0; +const injectx_1 = require("injectx"); +const GetUserRepository = ({ db }) => (username) => { + return db.users.find(user => user.username === username); +}; +exports.GetUserRepository = GetUserRepository; +exports.getUserReposistory = (0, injectx_1.InjectIn)(exports.GetUserRepository); diff --git a/examples/hello-world-app/src/index.d.ts b/examples/hello-world-app/src/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/examples/hello-world-app/src/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/examples/hello-world-app/src/index.js b/examples/hello-world-app/src/index.js new file mode 100644 index 0000000..a39671b --- /dev/null +++ b/examples/hello-world-app/src/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const diInit_1 = require("./diInit"); +(0, diInit_1.DiInit)(); +const getUser_repository_1 = require("./getUser.repository"); +console.log((0, getUser_repository_1.getUserReposistory)("tarek")); diff --git a/package.json b/package.json index 008c2ce..8b0320a 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "injectx", - "version": "1.0.2", + "version": "1.0.3", "main": "lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "nodemon", "build": "tsc -p .", - "publish": "npm run build & npm publish" + "prepublishOnly": "npm run build" }, "repository": { "type": "git", diff --git a/tsconfig.json b/tsconfig.json index a0c1708..4fc72d5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -66,5 +66,6 @@ "resolveJsonModule": true, /* Include modules imported with '.json' extension */ "skipLibCheck": true, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + }, + "exclude": ["examples/**", "lib"] }