GouriSurada3 / Chessboard

This project identifies valid moves for different chess pieces on a chessboard.
0 stars 0 forks source link

This issue created for testing Github This issue created for testing Github This issue created for testing Github This issue created for testing Github This issue created for testing Github This issue created for testing Github This issue created for testing Github This issue created for testing Github This issue created for testing GithubThis issue created for testing GithubThis issue created for testing GithubThis issue created for testing GithubThis issue created for testing GithubThis issue created for testing GithubThis issue created for testing GithubThis issue created for testing GithubThis issue created for testing Github #14

Open bcgiri31 opened 1 month ago

bcgiri31 commented 1 month ago

hopefully github works /* **** {COPYRIGHT-TOP} ****

hopefully github works

bcgiri31 commented 1 month ago

testing comment1

bcgiri31 commented 1 month ago

/* **** {COPYRIGHT-TOP} ****

const featureCheck = require('@omaas/common-auth').swaggerFeatureCheck;

const router = require('express').Router();

const apiDefs = YAML.load(path.join(__dirname, 'apis.yaml')); const config = require('../etc/config');

var swaggerLogger = logging.getLogger('swagger');

function loadSwaggerApis(callback) { let uirouter = express.Router(); let apirouter = express.Router();

router.use(uirouter, apirouter);

apirouter.use("/api/incimgnt",authentication["staticAuthentication"]);
// Now actualy load all the swagger routes
async.eachOf(apiDefs.apis, (apiDef, apiKey, eachCB) => {
  let doc;
  try {
    if (apiDef.specType === 'json') {
      doc = require(apiDef.spec);
    } else {
      doc = YAML.load(path.resolve(__dirname, apiDef.spec));
    }
  } catch (ex) {
    swaggerLogger.error(`Unable to load API ${apiKey}, the spec was invalid`,
      ex);
    return;
  }

  let docGen;
  if (apiDef.docGenerator) {
    docGen = require(apiDef.docGenerator);
  }

  swaggerTools.initializeMiddleware(doc, function inlineInit(swagger) {
    // The API specifications should not be publicly available
    if (process.env.ENABLE_SWAGGER_UI) {
      uirouter.use(apiDef.docsApi, (req, res) => {
        if (docGen) {
          docGen(doc, req).then(genDocs => res.send(genDocs));
        } else {
          res.send(doc);
        }
      });
      uirouter.get(new RegExp(apiDef.docsUrl + '/(index.html?)?$'), swaggerUiIndex(apiDef.docsApi));
      uirouter.get(new RegExp(apiDef.docsUrl + '$'), (req, res) => res.redirect(apiDef.docsUrl + '/'));
      uirouter.use(apiDef.docsUrl, express.static(swaggerUI.getAbsoluteFSPath()));
    }

    if (apiDef.legacyMode) {
      apirouter.use(doc.basePath, (req, res, next) => {
        req.legacyMode = true;
        next();
      });
    }

    if (!apiDef.authentication) {
      throw new Error('Please define an authentication scheme for API ' + apiDef.spec);
    }

    if (apiDef.authentication !== 'NONE') {
      apirouter.use(logging.startTaskMiddleware(apiDef.authentication));
      apirouter.use(doc.basePath, authentication[apiDef.authentication]);
      console.log({basePath:doc.basePath,"authMethod":authentication[apiDef.authentication],apiDef,doc},"DDDDDDDDDDDDDD")
      apirouter.use(logging.finishTaskMiddleware(apiDef.authentication));
    }

    // Interpret Swagger resources and attach metadata to request - must be
    // first in swagger-tools middleware chain
    apirouter.use(swagger.swaggerMetadata());

    // Validate Swagger requests
    apirouter.use(swagger.swaggerValidator({validateResponse: false}));

    // Route validated requests to appropriate controller
    apirouter.use(swagger.swaggerRouter({
      controllers: [path.resolve(__dirname, apiDef.controllers)]
    }));

    eachCB(null);
  });
}, callback);

}

function swaggerUiIndex(apiDocsPath) { // Only run during startup, so fs.readFileSync used. let template = fs.readFileSync(path.resolve(swaggerUI.getAbsoluteFSPath(), './index.html'), 'utf-8'); let apiDocsUrl = config.externalurl('collabopsauth', apiDocsPath);

return function (req, res) {
  res.send(template.replace(/https?[:/]+petstore.swagger.io.*?swagger.json/, apiDocsUrl +
    (req.query.offerings ? '?offerings=' + req.query.offerings.replace(/[^A-z-_]/g, '') : '')));
};

}

function init(done) { async.waterfall([ function protectSwaggerValidation(cbAsync) { // Swagger validation does not handle 304 properly router.use(errorhandlers.responseValidationProtection1); cbAsync(null); }, loadSwaggerApis, function postSwaggerHandling(cbAsync) { // Swagger validation does not handle 304 properly router.use(errorhandlers.responseValidationProtection2);

    // Check and form swagger error message
    router.use(errorhandlers.swaggerValidation);

    cbAsync();
  }
], done);

}

init((err) => { if (err) { return swaggerLogger.error('Error loading swagger APIs', err); }

return swaggerLogger.info('Swagger APIs loaded');

});

module.exports = router;