diff --git a/backend/src/index.js b/backend/src/index.js deleted file mode 100644 index ddd9542..0000000 --- a/backend/src/index.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const express_1 = __importDefault(require("express")); -const dotenv_1 = __importDefault(require("dotenv")); -const jobIngestionRoutes_1 = __importDefault(require("./routes/jobIngestionRoutes")); -const jobSearchRoutes_1 = __importDefault(require("./routes/jobSearchRoutes")); -dotenv_1.default.config(); -const app = (0, express_1.default)(); -const PORT = process.env.PORT || 3000; -app.use(express_1.default.json()); -app.use(jobIngestionRoutes_1.default); -app.use(jobSearchRoutes_1.default); -app.listen(PORT, () => { - console.log(`Server is running on port ${PORT}`); -}); diff --git a/backend/src/routes/jobIngestionRoutes.js b/backend/src/routes/jobIngestionRoutes.js deleted file mode 100644 index 37f247f..0000000 --- a/backend/src/routes/jobIngestionRoutes.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const express_1 = __importDefault(require("express")); -const jobIngestionController_1 = require("../controllers/jobIngestionController"); -const router = express_1.default.Router(); -router.post('/api/ingest-jobs', jobIngestionController_1.ingestJobOffers); -exports.default = router; diff --git a/backend/src/routes/jobSearchRoutes.js b/backend/src/routes/jobSearchRoutes.js deleted file mode 100644 index 2c37a65..0000000 --- a/backend/src/routes/jobSearchRoutes.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const express_1 = __importDefault(require("express")); -const jobSearchController_1 = require("../controllers/jobSearchController"); -const router = express_1.default.Router(); -router.get('/api/jobs', jobSearchController_1.searchLocalJobOffers); -exports.default = router; diff --git a/backend/src/services/FranceTravailService.js b/backend/src/services/FranceTravailService.js deleted file mode 100644 index 5a2e338..0000000 --- a/backend/src/services/FranceTravailService.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const axios_1 = __importDefault(require("axios")); -class FranceTravailService { - constructor() { - this.accessToken = null; - this.tokenExpiration = null; - this.realm = '/partenaire'; - this.clientId = process.env.FRANCE_TRAVAIL_CLIENT_ID || ''; - this.clientSecret = process.env.FRANCE_TRAVAIL_CLIENT_SECRET || ''; - this.tokenUrl = process.env.FRANCE_TRAVAIL_TOKEN_URL || ''; - this.apiUrl = process.env.FRANCE_TRAVAIL_API_URL || ''; - this.scope = process.env.FRANCE_TRAVAIL_SCOPE || ''; - } - authenticate() { - return __awaiter(this, void 0, void 0, function* () { - var _a; - try { - const response = yield axios_1.default.post(this.tokenUrl, null, { - params: { - realm: this.realm, - grant_type: 'client_credentials', - client_id: this.clientId, - client_secret: this.clientSecret, - scope: this.scope, - }, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - }); - this.accessToken = response.data.access_token; - this.tokenExpiration = Date.now() + response.data.expires_in * 1000; - } - catch (error) { - const axiosError = error; - console.error('Authentication failed:', ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.data) || axiosError.message); - throw new Error('Failed to authenticate with France Travail API'); - } - }); - } - ensureValidToken() { - return __awaiter(this, void 0, void 0, function* () { - if (!this.accessToken || (this.tokenExpiration && Date.now() >= this.tokenExpiration)) { - yield this.authenticate(); - } - }); - } - getJobOffers(params) { - return __awaiter(this, void 0, void 0, function* () { - var _a; - yield this.ensureValidToken(); - try { - const response = yield axios_1.default.get(this.apiUrl, { - headers: { - Authorization: `Bearer ${this.accessToken}`, - }, - params: Object.assign(Object.assign({}, params), { range: (params === null || params === void 0 ? void 0 : params.range) || '0-9' }), - }); - return response.data; - } - catch (error) { - const axiosError = error; - console.error('Failed to fetch job offers:', ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.data) || axiosError.message); - throw new Error('Failed to fetch job offers from France Travail API'); - } - }); - } -} -exports.default = new FranceTravailService();