Skip to content
Snippets Groups Projects
init-index.js 1.4 KiB
Newer Older
/* eslint-disable @typescript-eslint/no-var-requires */
const axios = require('axios');
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

axios
  .post('http://localhost:3000/api/auth/login', {
Etienne LOUPIAS's avatar
Etienne LOUPIAS committed
    email: 'admin@admin.com',
    password: process.env.USER_PWD,
  })
  .then((res) => {
    const config = {
      headers: { Authorization: `Bearer ${res.data.accessToken}` },
    };
    axios
      .post('http://localhost:3000/api/structures/resetSearchIndex', {}, config)
      .then((res) => {
Hugo SUBTIL's avatar
Hugo SUBTIL committed
        console.log(`Structures | statusCode: ${res.status}`);
      })
      .catch((error) => {
        console.error('Error in structure search reset');
Hugo SUBTIL's avatar
Hugo SUBTIL committed
        console.error(error);
      });
    axios
      .post('http://localhost:3000/api/employer/searchIndex', {}, config)
      .then((res) => {
        console.log(`Employers | statusCode: ${res.status}`);
      })
      .catch((error) => {
        console.error('Error in employer search reset');
        console.error(error);
      });
Etienne LOUPIAS's avatar
Etienne LOUPIAS committed
    axios
      .post('http://localhost:3000/api/userRegistry/searchIndex', {}, config)
      .then((res) => {
        console.log(`Users | statusCode: ${res.status}`);
      })
      .catch((error) => {
        console.error('Error in user search reset');
Etienne LOUPIAS's avatar
Etienne LOUPIAS committed
        console.error(error);
      });
  })
  .catch((error) => {
    console.error('Error in auth');
    console.error(error);
  });