Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use strict';
import { readFileSync } from 'node:fs';

const Boom = require('@hapi/boom');
const Hoek = require('@hapi/hoek');
import * as Boom from '@hapi/boom';
import * as Hoek from '@hapi/hoek';


const internals = {};

const Package = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));

exports.plugin = {
pkg: require('../package.json'),

const plugin = {
pkg: Package,
requirements: {
hapi: '>=20.0.0'
},
Expand Down Expand Up @@ -83,3 +85,6 @@ internals.implementation = function (server, options) {

return scheme;
};


export { plugin };
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@hapi/basic",
"description": "Basic authentication plugin",
"version": "7.0.2",
"version": "8.0.0",
"type": "module",
"repository": "git://github.com/hapijs/basic",
"main": "lib/index.js",
"exports": "./lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib"
Expand Down Expand Up @@ -33,7 +34,7 @@
"typescript": "^5.1.3"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test": "lab -a @hapi/code -Y",
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
},
"license": "BSD-3-Clause"
Expand Down
11 changes: 5 additions & 6 deletions test/esm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
import * as Code from '@hapi/code';
import * as Lab from '@hapi/lab';

const Code = require('@hapi/code');
const Lab = require('@hapi/lab');


const { before, describe, it } = exports.lab = Lab.script();
const lab = Lab.script();
const { before, describe, it } = lab;
const expect = Code.expect;
export { lab };


describe('import()', () => {
Expand All @@ -20,7 +20,6 @@ describe('import()', () => {
it('exposes all methods and classes as named imports', () => {

expect(Object.keys(Basic)).to.equal([
'default',
'plugin'
]);
});
Expand Down
16 changes: 8 additions & 8 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

const Basic = require('..');
const Boom = require('@hapi/boom');
const Code = require('@hapi/code');
const Hapi = require('@hapi/hapi');
const Lab = require('@hapi/lab');
import * as Basic from '../lib/index.js';
import * as Boom from '@hapi/boom';
import * as Code from '@hapi/code';
import * as Hapi from '@hapi/hapi';
import * as Lab from '@hapi/lab';


const internals = {};


const { it, describe } = exports.lab = Lab.script();
const lab = Lab.script();
const { it, describe } = lab;
const expect = Code.expect;
export { lab };


describe('Basic authentication', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// from https://github.com/hapijs/hapi-auth-basic#hapi-auth-basic

import * as Basic from '..';
import * as Basic from '../lib/index.js';
import { Server } from '@hapi/hapi';
import { types } from '@hapi/lab';

Expand Down
Loading