input: Write a function to create a basic REST API with authentication and endpoints in Python using Flask and Flask-RESTful. The API should include JWT authentication and have at least two endpoints: one for getting an item by its name and another for listing all items. If the item is not found, return a 404 status code. The function should return the Flask app object.
  assert create_rest_api() instanceof Flask
  assert create_rest_api().test_client().get('/items')
  assert create_rest_api().test_client().post('/item/test').status_code == 201
output: 
  def create_rest_api():
      from flask import Flask, jsonify, request
      from flask_restful import Api, Resource
      from flask_jwt_extended import JWTManager, jwt_required, create_access_token
  
      app = Flask(__name__)
      api = Api(app)
      app.config['JWT_SECRET_KEY'] = 'super-secret'
      jwt = JWTManager(app)
  
      items = []
  
      class Item(Resource):
          @jwt_required()
          def get(self, name):
              item = next((item for item in items if item['name'] == name), None)
              if item:
                  return jsonify(item)
              return {'message': 'Item not found'}, 404
  
          @jwt_required()
          def post(self, name):
              if next((item for item in items if item['name'] == name), None):
                  return {'message': "An item with name '{}' already exists.".format(name)}, 400
              item = {'name': name, 'price': request.json['price']}
              items.append(item)
              return item, 201
  
      class ItemList(Resource):
          @jwt_required()
          def get(self):
              return jsonify(items)
  
      api.add_resource(Item, '/item/<string:name>')
      api.add_resource(ItemList, '/items')
  
      @app.route('/login', methods=['POST'])
      def login():
          username = request.json.get('username', None)
          password = request.json.get('password', None)
          if username != 'test' or password != 'test':
              return jsonify({"msg": "Bad username or password"}), 401
          access_token = create_access_token(identity=username)
          return jsonify(access_token=access_token)
  
      return app
  