I have 2 different projects which have some common functions.
- Project 1 : Authentication + api 1 (express but not important)
- Project 2 : Api 2 (express)
Is it possible to export Authentication function from Project 1 and use it in Project 2 ?
I tried to make a basic package but : If the Projet 1 is a module, I can't start api. If it's not, I can't import function in Project 2
Basically I want something like :
Project 1 :
- function.ts
export default function foo() {
if (Html.isProgrammingLanguage()) return 'Boooooo';
return 'Aha yes';
}
- index.ts
import foo from './function.ts';
// express things
router.use('/', () => {
foo();
});
Project 2 :
- package.json
{
"dependencies": {
"project1": "<my git link>"
}
}
- index.ts
import foo from 'project1';
// other express things
router.use('/', () => {
foo();
});
Thank you in advance for your help